Aspect Ratio

Set the aspect ratio of an element.

Widely available

This feature is well established and works across many devices and browser versions.

Chrome
Edge
Firefox
Safari
Something went wrong while fetching the data.

Usage

Auto

Allow the element to maintain its default aspect ratio.

Frangipani
<div class="ar-auto h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

1/1

Enforce a square aspect ratio.

Frangipani
<div class="ar-1/1 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

1/2

Enforce a vertical aspect ratio.

Frangipani
<div class="ar-1/2 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

16/9

Enforce a widescreen aspect ratio.

Frangipani
<div class="ar-16/9 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

2/1

Enforce a horizontal aspect ratio.

Frangipani
<div class="ar-2/1 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

2/3

Enforce a vertical aspect ratio.

Frangipani
<div class="ar-2/3 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

3/2

Enforce a horizontal aspect ratio.

Frangipani
<div class="ar-3/2 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

9/16

Enforce a vertical aspect ratio.

Frangipani
<div class="ar-9/16 h-32">
<img class="of-c w-full h-full" src="/img/frangipani.jpg" alt="Frangipani" />
</div>

Responsiveness

Use breakpoint prefixes to target different screen sizes. Styles apply from the breakpoint & up.

Target viewport sizes with breakpoint prefixes.

sm:ar-*
Small640px
md:ar-*
Medium768px
lg:ar-*
Large1024px
xxl:ar-*
Extra Large1536px

Hover State

Apply styles conditionally on hover using the h: prefix.

Add the h: prefix to apply styles only when the user hovers over the element.

Syntax:h:ar-*