媒体
图文块
带边缘处理和图注的图片或视频。
本页内容
图文块由图注和一张图片、一段视频或一幅绘图组成。媒体沿用表面的圆角,并在边缘内侧加一圈细线,让浅色图像的边界清晰可辨,也让深色图像在边缘处不显突兀。图注紧贴媒体下方,样式低调。适合放大查看的图片可在灯箱中打开。
图文块
<figure class="figure max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 3 / 2"> <figcaption class="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption></figure><figure className="figure max-w(360) mx-auto"> <img className="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style={{ '--figure-ratio': '3 / 2' } as React.CSSProperties} /> <figcaption className="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption></figure><figure class="figure max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 3 / 2"> <figcaption class="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption></figure><template> <figure class="figure max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 3 / 2"> <figcaption class="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption> </figure></template>为媒体设置 --figure-ratio,可在加载前确定显示区域的比例,加载后媒体会覆盖该区域。省略时,媒体保持自身比例。无论是否设置,都应在 <img> 上写明 width 和 height,让浏览器预留空间。
#带框
figure-framed 将媒体放入托盘,四周内缩 4px,像照片嵌在卡纸衬框里,图注也移到框内。托盘的圆角半径等于媒体的圆角半径加上内缩量,使圆角处的间距也保持一致。
带框
<figure class="figure figure-framed max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 16 / 9"> <figcaption class="figure-caption">Figure 2. The same stone, framed.</figcaption></figure><figure className="figure figure-framed max-w(360) mx-auto"> <img className="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style={{ '--figure-ratio': '16 / 9' } as React.CSSProperties} /> <figcaption className="figure-caption">Figure 2. The same stone, framed.</figcaption></figure><figure class="figure figure-framed max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 16 / 9"> <figcaption class="figure-caption">Figure 2. The same stone, framed.</figcaption></figure><template> <figure class="figure figure-framed max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 16 / 9"> <figcaption class="figure-caption">Figure 2. The same stone, framed.</figcaption> </figure></template>#居中
figure-center 让图注居中并均衡分行,适用于正文栏中独立呈现的图文块。
居中
<figure class="figure figure-center max-w(240) mx-auto"> <img class="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style="--figure-ratio: 1"> <figcaption class="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption></figure><figure className="figure figure-center max-w(240) mx-auto"> <img className="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style={{ '--figure-ratio': '1' } as React.CSSProperties} /> <figcaption className="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption></figure><figure class="figure figure-center max-w(240) mx-auto"> <img class="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style="--figure-ratio: 1"> <figcaption class="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption></figure><template> <figure class="figure figure-center max-w(240) mx-auto"> <img class="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style="--figure-ratio: 1"> <figcaption class="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption> </figure></template>#无障碍
- 将
<figure>与<figcaption>搭配使用,图注即为图文块的无障碍名称。 - 图注不能替代
alt。替代文本描述图像展示的内容,图注说明图像为何出现在这里。若图注已涵盖全部信息,使用空的替代文本alt=""可避免重复朗读。 - 媒体边缘内侧的细线仅作装饰,随配色方案变化。在强制颜色模式下,带框图文块使用系统轮廓线。
#类名
| 类名 | 说明 |
|---|---|
figure | 图文组合,媒体在上,说明文字在下 |
figure-framed | 媒体置于托盘中,向内缩进 4px,说明文字位于边框内。与 figure 一同使用 |
figure-center | 用于在正文栏中独立呈现的 figure,图注居中,各行长度均衡。与 figure 一同使用 |
figure-media | img、video、svg 或任意块级元素,采用表面圆角,内沿绘制一圈细线 |
figure-caption | 媒体下方的小号低对比度说明文字 |
#自定义属性
| 属性 | 默认值 | 说明 |
|---|---|---|
--figure-radius | var(--radius-surface) | 媒体的圆角 |
--figure-ratio | 媒体加载前按此宽高比预留空间,加载后铺满该区域。未设置时,媒体保持自身比例。在 figure-media 上设置 |