CSSPropertyRule:syntax 属性
Baseline
2024
Newly available
Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
CSSPropertyRule
接口的只读属性 syntax
返回由 @property
规则表示的自定义属性注册的字面语法,用于控制该属性值在计算值时如何被解析。
值
字符串。
示例
下面的样式表包含一个 @property
规则。返回的第一个 CSSRule
将是一个代表此规则的 CSSPropertyRule
。syntax
属性返回字符串字面量 "<color>"
。
css
@property --property-name {
syntax: "<color>";
inherits: false;
initial-value: #c0ffee;
}
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].syntax); // “<color>”
规范
Specification |
---|
CSS Properties and Values API Level 1> # dom-csspropertyrule-syntax> |
浏览器兼容性
Loading…