Docs
纵横比

纵横比

按所需比例显示内容。

Photo by Drew Beamer

安装

¥Installation

pnpm dlx shadcn@latest add aspect-ratio

用法

¥Usage

import Image from "next/image"
 
import { AspectRatio } from "@/components/ui/aspect-ratio"
<div className="w-[450px]">
  <AspectRatio ratio={16 / 9}>
    <Image src="..." alt="Image" className="rounded-md object-cover" />
  </AspectRatio>
</div>