StylePropertyMapReadOnly: size 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

sizeStylePropertyMapReadOnly 接口的一个只读属性,它返回一个无符号长整型整数,表示 StylePropertyMapReadOnly 对象的大小。

无符号长整型。

示例

在这里,我们使用 size 属性返回按钮元素的 computedStyleMap 中的总条目数。

js
// grab our element
const buttonEl = document.querySelector("button");

// we can retrieve all computed styles with `computedStyleMap`
const allComputedStyles = buttonEl.computedStyleMap();

// use size to get the total styles within the map
const amountStyles = allComputedStyles.size;
console.log(amountStyles); // logs 338

规范

规范
CSS 类型化 OM Level 1
# dom-stylepropertymapreadonly-size

浏览器兼容性