例項屬性
繼承其祖先 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 |
瀏覽器相容性
載入中…