Skip to content

Aspect Ratio

Aspect ratio is typically denoted by two integers separated by a colon, representing width and height, such as x:y. Maintaining a precise ratio between the width and height of responsive elements on a webpage is occasionally needed.

RatioClass nameCopy code

  • 1:1
    .aspect-1x1
  • 2:1
    .aspect-2x1
  • 3:1
    .aspect-3x1
  • 4:3
    .aspect-4x3
  • 16:9
    .aspect-16x9
  • 21:9
    .aspect-21x9

Example

iFrame

Set an iframe to be 16x9, for instance for a video (resize the preview window and the iframe maintains ratio).