CSSPropertyRule.name
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.
Thuộc tính chỉ đọc name của giao diện CSSPropertyRule trả về tên của quy tắc thuộc tính CSS tùy chỉnh được đại diện bởi đối tượng @property. Đây luôn bắt đầu bằng hai dấu gạch ngang.
Giá trị
Chuỗi.
Ví dụ
Stylesheet này chứa một đơn @property. CSSPropertyRule đầu tiên được trả về sẽ đại diện cho thuộc tính này.
css
@property --property-name {
syntax: "<color>";
inherits: false;
initial-value: #c0ffee;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].name); // "--property-name"
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| CSS Properties and Values API Level 1> # dom-csspropertyrule-name> |