?
This document uses PHP Chinese website manual Release
HTML<figure> 元素
代表一段獨(dú)立的內(nèi)容, 經(jīng)常與說明(caption) <figcaption>
配合使用,
并且作為一個(gè)獨(dú)立的引用單元。當(dāng)它屬于主體(main flow)時(shí),它的位置獨(dú)立于主體。這個(gè)標(biāo)簽經(jīng)常是在主文中引用的圖片,插圖,表格,代碼段等等,當(dāng)這部分轉(zhuǎn)移到附錄中或者其他頁面時(shí)不會(huì)影響到主體。
內(nèi)容類別 | 流量?jī)?nèi)容,切片根,可觸及的內(nèi)容。 |
---|---|
允許的內(nèi)容 | 一個(gè)<figcaption>元素,其次是流程內(nèi)容; 或流量?jī)?nèi)容后跟一個(gè)<figcaption>元素; 或流量?jī)?nèi)容。 |
標(biāo)記遺漏 | 沒有,起始和結(jié)束標(biāo)簽都是強(qiáng)制性的。 |
允許的父母 | 任何接受Flow內(nèi)容的元素。 |
允許ARIA角色 | 組,演示文稿 |
DOM界面 | HTML元素 |
這個(gè)標(biāo)簽只包含 全局屬性.
使用主義
通常,a <figure>
是在文檔的主流程中引用的圖像,插圖,圖表,代碼段等,但可以移動(dòng)到文檔的另一部分或附錄中,而不影響主流程。
作為一個(gè) sectioning root, <figure> 元素內(nèi)容的綱要是被文檔的主綱要排除在外的.
可以通過在<figure>元素中插入一個(gè)<figcaption>
來為其關(guān)聯(lián)一個(gè)標(biāo)題(作為它的第一個(gè)或者最后一個(gè)子元素).
<!-- Just a figure --><figure> <img src="https://developer.cdn.mozilla.net/media/img/mdn-logo-sm.png" alt="An awesome picture"></figure><p></p><!-- Figure with figcaption --><figure> <img src="https://developer.cdn.mozilla.net/media/img/mdn-logo-sm.png" alt="An awesome picture"> <figcaption>Fig1. MDN Logo</figcaption></figure><p></p>
圖.1.MDN標(biāo)志
<figure> <figcaption>Get browser details using navigator</figcaption> <pre>function NavigatorExample() { var txt; txt = "Browser CodeName: " + navigator.appCodeName; txt+= "Browser Name: " + navigator.appName; txt+= "Browser Version: " + navigator.appVersion ; txt+= "Cookies Enabled: " + navigator.cookieEnabled; txt+= "Platform: " + navigator.platform; txt+= "User-agent header: " + navigator.userAgent;} </pre></figure>
使用導(dǎo)航器獲取瀏覽器詳情
function NavigatorExample() { var txt; txt = "Browser CodeName: " + navigator.appCodeName; txt+= "Browser Name: " + navigator.appName; txt+= "Browser Version: " + navigator.appVersion ; txt+= "Cookies Enabled: " + navigator.cookieEnabled; txt+= "Platform: " + navigator.platform; txt+= "User-agent header: " + navigator.userAgent;}
<figure> <figcaption><cite>Edsger Dijkstra :-</cite></figcaption> <p>"If debugging is the process of removing software bugs, <br /> then programming must be the process of putting them in"</p></figure>
Edsger Dijkstra :-
“如果調(diào)試是消除軟件錯(cuò)誤的過程,
那么編程必須是將它們放入“
<figure> 標(biāo)簽可以用來為一首詩添加格式
<figure> <p> Depression is running through my head,<br> These thoughts make me think of death,<br> A darkness which blanks my mind,<br> A walk through the graveyard, what can I find?.... </p> <figcaption><cite>Depression</cite>. By: Darren Harris</figcaption></figure>
Specification | Status | Comment |
---|---|---|
HTML Living StandardThe definition of '<figure>' in that specification. | Living Standard | |
HTML5The definition of '<figure>' in that specification. | Recommendation |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | 8 | (Yes) | 4 | 9 | 11 | 5.1 |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | 4 | 9 | 11 | 5.1 |