ToolHop.

ADVERT

๐Ÿ“ Aspect Ratio Box

Generate aspect-ratio CSS plus the padding-bottom fallback snippet. Copy a ready-to-use responsive wrapper for any width and height.

Aspect Ratio Box Generator

Create a responsive container with modern aspect-ratiosupport and an automatic padding-bottom fallback for older browsers.

Dimensions

Class name

Aspect ratio
16:9 (1.7778:1)
Fallback padding
calc(100% * 9 / 16)

Preview

Aspect ratio16:9padding-bottom 56.25%

The box uses both the aspect-ratio property and the padding-bottom fallback, matching the generated CSS.

CSS output

.aspect-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.aspect-box::before {
  content: "";
  display: block;
  padding-bottom: calc(100% * 9 / 16);
}

@supports (aspect-ratio: 1 / 1) {
  .aspect-box::before {
    display: none;
    padding-bottom: 0;
  }
}

.aspect-box > * {
  position: absolute;
  inset: 0;
}

ADVERT

ADVERT

Aspect Ratio Box Generator - CSS Aspect Ratio with Fallback