此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

CSSPropertyRule:inherits 属性

基线 2024
最近可用

自 July 2024 起,此特性已在最新浏览器中得到支持。但在较旧的设备或浏览器中可能无法运行。

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

布尔值。

示例

下面的样式表包含一个 @property 规则。返回的第一个 CSSRule 将是一个代表此规则的 CSSPropertyRuleinherits 属性返回等于 CSS 中 inherits 属性的布尔值 false

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 Properties and Values API Level 1
# dom-csspropertyrule-inherits

浏览器兼容性