宽高比组件

按指定比例显示内容

Photo by Drew Beamer

安装方法

pnpm dlx shadcn-vue@latest add aspect-ratio

使用示例

vue
<script setup lang="ts">
import { AspectRatio } from '@/components/ui/aspect-ratio'
</script>

<template>
  <div class="w-[450px]">
    <AspectRatio :ratio="16 / 9">
      <img src="..." alt="图像" class="rounded-md object-cover w-full h-full">
    </AspectRatio>
  </div>
</template>
Edit this page on GitHub