CSSScopeRule
Baseline
2025
Newly available
Since December 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Giao diện CSSScopeRule của CSS Object Model biểu thị at-rule CSS @scope.
Thuộc tính phiên bản
Kế thừa thuộc tính từ các lớp tổ tiên CSSGroupingRule và CSSRule.
Phương thức phiên bản
Kế thừa phương thức từ các lớp tổ tiên CSSGroupingRule và CSSRule.
Ví dụ
>Truy cập thông tin @scope trong JavaScript
Giả sử đây là stylesheet duy nhất được gắn vào tài liệu:
css
@scope (.outer) to (.inner) {
:scope {
background: yellow;
}
}
JavaScript sau có thể được sử dụng để truy cập thông tin về khối @scope được chứa:
js
const scopeBlock = document.styleSheets[0].cssRules[0];
console.log(scopeBlock.start); // Returns ".outer"
console.log(scopeBlock.end); // Returns ".inner"
Thông số kỹ thuật
| Specification |
|---|
| CSS Cascading and Inheritance Level 6> # cssscoperule> |