CSSOM
The read-only nameList property of the CSSLayerStatementRule interface returns the list of associated cascade layer names. The names can't be modified.
Value
An Array of strings, each representing a cascade layer represented by the @layer statement rule.
Examples
HTML
<div></div>
CSS
@layer layerName, layerName2;
@layer layerName3 {
div {
font-family: serif;
}
}
JavaScript
const item = document.getElementsByTagName("div")[0];
const rules = document.getElementById("css-output").sheet.cssRules;
const layerStatementRule = rules[0]; // A CSSLayerStatementRule
const layerBlockRule = rules[1]; // A CSSLayerBlockRule; no nameList property.
item.textContent = `@layer declares the following layers: ${layerStatementRule.nameList.join(
", ",
)}.`;
Specifications
Browser compatibility
See also
- CSSLayerBlockRule.name
- @layer
- The
@layerstatement at-rule for named layers
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
