HTML <figure> 标签
示例
使用 <figure> 元素来标记文档中的图片,使用 <figcaption> 元素来定义图片的标题
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
<figcaption>图1 - 特鲁利,普利亚,意大利。</figcaption>
</figure>
自己动手试一试 »
更多“自己尝试”的例子见下文。
定义和用法
<figure>
标签指定自包含内容,如插图、图表、照片、代码列表等。
虽然 <figure>
元素的内容与主体流程相关,但其位置独立于主体流程,如果删除它,不应影响文档的流程。
提示:<figcaption> 元素用于为 <figure>
元素添加标题。
浏览器支持
表格中的数字表示完全支持该元素的首个浏览器版本。
元素 | |||||
---|---|---|---|---|---|
<figure> | 8.0 | 9.0 | 4.0 | 5.1 | 11.0 |
全局属性
<figure>
标签也支持 HTML 全局属性。
事件属性
<figure>
标签也支持 HTML 事件属性。
更多示例
示例
使用 CSS 样式化 <figure> 和 <figcaption>
<html>
<head>
<style>
figure {
border: 1px #cccccc solid;
padding: 4px;
margin: auto;
}
figcaption {
background-color: black;
color: white;
font-style: italic;
padding: 2px;
text-align: center;
}
</style>
</head>
<body>
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
<figcaption>图1 - 特鲁利,普利亚,意大利</figcaption>
</figure>
</body>
</html>
自己动手试一试 »
相关页面
HTML DOM 参考:Figure 对象
默认 CSS 设置
大多数浏览器会以以下默认值显示 <figure>
元素
示例
figure {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
}
自己动手试一试 »