?
本文檔使用 php中文網手冊 發(fā)布
HTML<figure> 元素
代表一段獨立的內容, 經常與說明(caption) <figcaption>
配合使用,
并且作為一個獨立的引用單元。當它屬于主體(main flow)時,它的位置獨立于主體。這個標簽經常是在主文中引用的圖片,插圖,表格,代碼段等等,當這部分轉移到附錄中或者其他頁面時不會影響到主體。
內容類別 | 流量內容,切片根,可觸及的內容。 |
---|---|
允許的內容 | 一個<figcaption>元素,其次是流程內容; 或流量內容后跟一個<figcaption>元素; 或流量內容。 |
標記遺漏 | 沒有,起始和結束標簽都是強制性的。 |
允許的父母 | 任何接受Flow內容的元素。 |
允許ARIA角色 | 組,演示文稿 |
DOM界面 | HTML元素 |
這個標簽只包含 全局屬性.
使用主義
通常,a <figure>
是在文檔的主流程中引用的圖像,插圖,圖表,代碼段等,但可以移動到文檔的另一部分或附錄中,而不影響主流程。
作為一個 sectioning root, <figure> 元素內容的綱要是被文檔的主綱要排除在外的.
可以通過在<figure>元素中插入一個<figcaption>
來為其關聯一個標題(作為它的第一個或者最后一個子元素).
<!-- 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標志
<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>
使用導航器獲取瀏覽器詳情
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 :-
“如果調試是消除軟件錯誤的過程,
那么編程必須是將它們放入“
<figure> 標簽可以用來為一首詩添加格式
<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 |