CardMedia 是 WordPress 组件库中的一个容器组件,用于在 Card 内承载全出血内容,如图像、视频或背景色。它作为 Card 的直接子组件使用,自动处理内部媒体元素的样式。
<img> 或视频元素。import { Card, CardBody, CardMedia } from '@wordpress/components';
const Example = () => (
<Card>
<CardMedia>
<img src="..." />
</CardMedia>
<CardBody>...</CardBody>
</Card>
); CardMedia provides a container for full-bleed content within a Card, such as images, video, or even just a background color.
import { Card, CardBody, CardMedia } from '@wordpress/components';
const Example = () => (
<Card>
<CardMedia>
<img src="..." />
</CardMedia>
<CardBody>...</CardBody>
</Card>
);
CardMedia can be placed in any order as a direct child of a Card (it can also exist as the only child component). The styles will automatically round the corners of the inner media element.