Skip to Content
文档

宽高比

用于嵌入响应式视频和地图等。

SourceStorybook
2 / 1

用法

¥Usage

import { AspectRatio } from "@chakra-ui/react"
<AspectRatio>
  <iframe
    title="naruto"
    src="https://www.youtube.com/embed/QhBnZ6NPOY0"
    allowFullScreen
  />
</AspectRatio>

示例

¥Examples

图片

¥Image

以下是如何嵌入宽高比为 4 x 3 的图片。

¥Here's how to embed an image that has a 4 by 3 aspect ratio.

naruto

视频

¥Video

要嵌入具有特定宽高比的视频,请使用 iframe,并将 src 指向视频链接。

¥To embed a video with a specific aspect ratio, use an iframe with src pointing to the link of the video.

谷歌地图

¥Google Map

以下是如何使用 AspectRatio 嵌入响应式 Google 地图。

¥Here's how to embed a responsive Google map using AspectRatio.

响应式

¥Responsive

以下是将响应式宽高比应用于框的示例。

¥Here's an example of applying a responsive aspect ratio to a box.

Box

属性

¥Props

这些属性可以传递给 AspectRatio 组件。

¥These props can be passed to the AspectRatio component.

PropDefaultType
ratio
ConditionalValue<number> | undefined

The aspect ratio of the Box. Common values are: `21/9`, `16/9`, `9/16`, `4/3`, `1.85/1`

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Previous

测试

Next

出血