在所需的宽高比内显示内容。
npx shadcn-ui@latest add aspect-ratio
import Image from "next/image" import { AspectRatio } from "@/components/ui/aspect-ratio"
<div className="w-[450px]"> <AspectRatio ratio={16 / 9}> <Image src="..." alt="图片" className="rounded-md object-cover" /> </AspectRatio> </div>