Aspect Ratio Calculator
Calculate exact aspect ratios with a live visual preview and get the best CSS code for the job.
Modern CSS (aspect-ratio)
aspect-ratio: 16 / 9;
Legacy CSS (Padding Hack)
.container { position: relative; width: 100%; padding-top:
56.25%; }
.content { position: absolute; top: 0; left: 0; width:
100%; height: 100%; }
📖 How to Use
- Base Ratio: type the ratio you want directly, or click a preset button to set it.
- Dimensions: enter the width or height you already know and the matching value is calculated for you based on the current ratio.
- Preview: the preview box reshapes in real time so you can see exactly how the ratio looks.
-
Code: both the modern
aspect-ratioproperty and thepadding-topfallback for older browsers are provided.