The native pixel dimensions of your image or video - what the browser knows before any CSS is applied.
/* waiting for input */
The Complete Guide to CSS Aspect Ratio and Object-Fit
If you have ever wrestled with a layout that looks perfect on a 1440px monitor and breaks completely on a 375px phone, you have felt the pain of hardcoded pixel heights. The CSS aspect-ratio property and object-fit family of values solve this at the browser level - no JavaScript, no padding hacks, no extra wrappers.
How to Use This Tool
- Set the container width in the Container Settings panel. Choose px for an absolute size or % for a fluid column width (the tool uses 800px as the reference container).
- Pick or type an aspect ratio. The container height is computed automatically from width divided by ratio.
- Enter the intrinsic dimensions of your media - the actual pixel size of the image or video file.
- Click an object-fit toggle to see how the browser would scale or crop the media. The pixel math cards update instantly.
- Adjust object-position to shift the crop anchor point - useful for keeping a face or logo in frame when using cover.
- Grab the resize handle (bottom-right corner of the teal dashed box in the preview) to manually resize the container and watch all numbers recalculate live.
Understanding the Pixel Math
When you use cover, the browser scales the image so its shorter side fills the container, then hides the overflow. This tool calculates exactly how many pixels are cropped from each axis so you know how much of your image is invisible.
With contain, the image shrinks until its longer side fits inside the container. The tool calculates the letterbox gap - the empty pixel height or width of the bars that appear on either side.
fill stretches the image to match the container exactly. Since no cropping or empty space occurs, the distortion is purely a ratio stretch. The tool expresses this as a percentage change in either axis.
scale-down behaves like contain if the image would need to be enlarged, or like none if the image is already smaller than the container. No scaling larger than the intrinsic size ever occurs.
none renders the image at its intrinsic dimensions with no scaling. If it is larger than the container, the overflow is hidden; if smaller, it floats at the object-position anchor surrounded by the container background.
The aspect-ratio Property vs. the Padding-Bottom Hack
Before aspect-ratio landed in browsers (broadly supported from mid-2021), developers faked responsive height using percentage padding. The trick relied on the fact that padding-top and padding-bottom percentages are calculated relative to the element's width, not its height. A 16:9 ratio required padding-bottom: 56.25% (9/16 = 0.5625) plus an absolutely-positioned inner element to hold actual content - awkward, fragile, and hard to read.
With aspect-ratio: 16 / 9 you write one property and remove the wrapper div entirely. The browser computes the height automatically whenever the width changes - whether from a CSS grid, flexbox, or viewport resizing.