suffix

Baseline 2023
新推出

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

@counter-style 規則的 suffix 描述符指定將新增到標記表示末尾的內容。

語法

css
/* <symbol> value: string, image, or identifier  */
suffix: "";
suffix: ") ";
suffix: url("bullet.png");

suffix 描述符接受單個 <symbol> 作為其值。

<symbol>

指定一個附加到標記表示的 <symbol>。它可以是 <string><image><custom-ident>

正式定義

相關的 at-rule@counter-style
初始值“.” (句號後跟一個空格)
計算值同指定值

正式語法

suffix = 
<symbol>

<symbol> =
<string> |
<image> |
<custom-ident>

<image> =
<url> |
<image()> |
<image-set()> |
<cross-fade()> |
<element()> |
<gradient>

<image()> =
image( <image-tags>? [ <image-src>? , <color>? ]! )

<image-set()> =
image-set( <image-set-option># )

<cross-fade()> =
cross-fade( <cf-image># )

<element()> =
element( <id-selector> )

<image-tags> =
ltr |
rtl

<image-src> =
<url> |
<string>

<image-set-option> =
[ <image> | <string> ] [ <resolution> || type( <string> ) ]?

<cf-image> =
[ <image> | <color> ] &&
<percentage [0,100]>?

<id-selector> =
<hash-token>

示例

為計數器設定字尾

HTML

html
<ul class="choices">
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>None of the above</li>
</ul>

CSS

css
@counter-style options {
  system: fixed;
  symbols: A B C D;
  suffix: ") ";
}

.choices {
  list-style: options;
}

結果

規範

規範
CSS Counter Styles Level 3
# counter-style-suffix

瀏覽器相容性

另見