实例属性
继承其祖先 CSSGroupingRule 和 CSSRule 的属性。
CSSLayerBlockRule.name只读-
一个包含关联的级联层名称的字符串。
实例方法
继承其祖先 CSSGroupingRule 和 CSSRule 的方法。
示例
HTML
html
<p>I am displayed in <code>color: rebeccapurple</code>.</p>
CSS
css
@layer special {
p {
color: rebeccapurple;
}
}
JavaScript
js
const item = document.getElementsByTagName("p")[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 layer = rules[0]; // A CSSLayerBlockRule
item.textContent = `The CSSLayerBlockRule is for the "${layer.name}" layer`;
结果
规范
| 规范 |
|---|
| CSS 级联与继承第五级 # csslayerblockrule |
浏览器兼容性
加载中…