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 级联和继承 第 5 级 # dom-csslayerstatementrule-namelist |
浏览器兼容性
BCD 表格仅在浏览器中加载