CSSPropertyRule: inherits property

Baseline 2024
新推出

自 ⁨2024 年 7 月⁩起,此功能可在最新的设备和浏览器版本上使用。此功能可能无法在较旧的设备或浏览器上使用。

CSSPropertyRule 接口的只读属性 inherits 返回由 @property 规则表示的自定义属性注册的继承标志,该布尔值描述了该属性是否默认继承。

布尔值。

示例

此样式表包含一个 @property 规则。返回的第一个 CSSRule 将是表示此规则的 CSSPropertyRuleinherits 属性返回布尔值 false,这是 CSS 中 inherits 属性的值。

css
@property --property-name {
  syntax: "<color>";
  inherits: false;
  initial-value: #c0ffee;
}
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].inherits); // false

规范

规范
CSS 属性和值 API Level 1
# dom-csspropertyrule-inherits

浏览器兼容性