CSSLayerStatementRule: nameList 屬性
CSSLayerStatementRule 介面的只讀 nameList 屬性返回關聯的級聯層名稱列表。這些名稱不可修改。
值
示例
HTML
html
<div></div>
CSS
css
@layer layerName, layerName2;
@layer layerName3 {
div {
font-family: serif;
}
}
JavaScript
js
const item = document.getElementsByTagName("div")[0];
const rules = document.styleSheets[1].cssRules;
// Note that stylesheet #1 is the stylesheet associated with this embedded example,
// while stylesheet #0 is the stylesheet associated with the whole MDN page
const layerStatementRule = rules[0]; // A CSSLayerStatementRule
const layerBlockRule = rules[1]; // A CSSLayerBlockRule; no nameList property.
item.textContent = `@layer declares the following layers: ${layer.nameList.join(
", ",
)}.`;
規範
| 規範 |
|---|
| CSS 級聯與繼承第五級 # dom-csslayerstatementrule-namelist |
瀏覽器相容性
載入中…