Aspect ratio
import { ApiTable } from "@/components/api-table.tsx"; import { Example } from "@/components/example.tsx"; import { Figure } from "@/components/figure.tsx"; import { UsingACustomValue, ResponsiveDesign, CustomizingYourTheme } from "@/components/content.tsx";
export const title = "aspect-ratio"; export const description = "Utilities for controlling the aspect ratio of an element.";
Examples¶
Basic example¶
Use aspect-<ratio> utilities like aspect-3/2 to give an element a specific aspect ratio:
<!-- [!code classes:aspect-3/2] -->
<img class="aspect-3/2 object-cover ..." src="/img/villas.jpg" />
Using a video aspect ratio¶
Use the aspect-video utility to give a video element a 16 / 9 aspect ratio:
<!-- [!code classes:aspect-video] -->
<iframe class="aspect-video ..." src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe>