CSSCounterStyleRule: range 屬性

Baseline 2023
新推出

自 2023 年 9 月起,此功能可在最新的裝置和瀏覽器版本上使用。此功能可能無法在較舊的裝置或瀏覽器上使用。

CSSCounterStyleRule 介面的 range 屬性用於獲取和設定 range 描述符的值。如果該描述符沒有設定值,則此屬性將返回一個空字串。

字串。

示例

下面的示例展示了一個 @counter-style 規則。在 JavaScript 中,myRules[0] 就是這個 @counter-style 規則,獲取 range 會返回 "2 4, 7 9" 這個值。

css
@counter-style range-multi-example {
  system: cyclic;
  symbols: "\25A0" "\25A1";
  range:
    2 4,
    7 9;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].range); // "2 4, 7 9"

規範

規範
CSS Counter Styles Level 3
# dom-csscounterstylerule-range

瀏覽器相容性