Tailwind Class Sorter
Sort Tailwind classes and detect conflicting utilities with a winner explanation.
OpenReserve the right space for images and video before they load, using one CSS property.
Choose 16:9, 4:3, 1:1 or 9:16 from the menu.
The .frame rule sets aspect-ratio, full width and object-fit.
Add the class to the img or video element itself.
Copy the rule or download aspect-ratio.css.
Blog thumbnails jump the page around as they load, and the layout shift score in your performance report keeps getting worse. Giving each frame a fixed ratio lets the browser reserve the space up front. Pick the ratio and copy the rule.
Select one of four ratios: 16 / 9 for landscape video and hero images, 4 / 3 for classic photos, 1 / 1 for avatars and product tiles, or 9 / 16 for vertical video and stories. The output is a .frame rule with aspect-ratio set to that value, width: 100% so it fills its column, and object-fit: cover so an image or video crops to fill the frame instead of stretching.
Put the class directly on the img or video element. If you place it on a wrapper div instead, object-fit has no effect on the wrapper; move that line to the media element inside. Note that aspect-ratio is ignored when both width and height are set explicitly, so remove any fixed height first. For media where cropping would cut off something important, such as a chart, switch object-fit to contain in the copied rule. The modern property replaces the old padding-top percentage hack, which this tool does not generate. To crop the source files themselves to the same shape, try the image cropper for pictures and the video crop tool for clips.
Keyboard shortcut
Answers for this tool. For site-wide help, open the FAQ hub.
They are still recommended. Browsers use the attributes to calculate a ratio before CSS loads, and the CSS rule then keeps the frame consistent across layouts.
If the element has both a fixed width and a fixed height, the property has nothing to calculate. Content taller than the ratio allows can also stretch it unless you set min-height: 0 or overflow: hidden.
Yes. Edit the copied value to aspect-ratio: 21 / 9. Any pair of positive numbers works, including decimals.