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

瀏覽器相容性