值
一個 CSSRule,表示包含規則的型別。如果當前規則位於媒體查詢內部,則返回 CSSMediaRule。否則返回 null。
示例
css
@media (width >= 500px) {
.box {
width: 100px;
height: 200px;
background-color: red;
}
body {
color: blue;
}
}
js
let myRules = document.styleSheets[0].cssRules;
let childRules = myRules[0].cssRules;
console.log(childRules[0].parentRule); // a CSSMediaRule
規範
| 規範 |
|---|
| CSS 物件模型 (CSSOM) # dom-cssrule-parentrule |
瀏覽器相容性
載入中…