Skip to content
MewixMewix

Aspect ratio box

Choose a widescreen, square, or custom width-to-height ratio, preview a media frame, and copy aspect-ratio CSS.

Updated by the Mewix team

16:9 video box without the padding hack

Before aspect-ratio, developers reserved height with padding-top: 56.25% on a wrapper. Modern browsers accept aspect-ratio: 16 / 9 directly. This tool presets widescreen, 4:3, square, 9:16 story, 21:9 ultrawide, or custom integers up to 32 per side.

aspect-ratio versus padding-bottom percentage

Percentage padding still works in older codebases but fights flex and grid sizing. Aspect-ratio participates in auto layout like width and height. Copied CSS also includes width: 100% and object-fit: cover so photos and videos fill the frame without stretching oddly—swap object-fit if you need letterboxing.

PresetCopied ratio
Widescreen16 / 9
Story9 / 16
Ultrawide21 / 9
Does aspect-ratio work on inline elements?

It applies to block and replaced elements best. Make the media wrapper display: block or flex item before expecting ratio to hold.