萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網頁製作 >> Div CSS 教學

CSS list-style-type 完整屬性值速查:列表項目符號自訂指南

list-style-type 屬性

設定列表項目(<li>、display: list-item)的前置標記樣式。當 list-style-image 為 none 或圖片無法載入時生效。

CSS1 關鍵字值(全瀏覽器支援)

關鍵字外觀適用場景
disc● 實心圓預設無序列表
circle○ 空心圓巢狀第二層
square■ 實心方塊巢狀第三層
decimal1, 2, 3...有序列表預設
lower-romani, ii, iii...附錄、腳註
upper-romanI, II, III...章節大綱
lower-alpha / lower-latina, b, c...子項目
upper-alpha / upper-latinA, B, C...主要項目
none無標記自訂圖示、導航選單

CSS2 國際化關鍵字(支援度較舊瀏覽器差)

關鍵字文字系統範例
armenian亞美尼亞數字Ա, Բ, Գ...
georgian喬治亞數字ა, ბ, გ...
cjk-ideographic中日韓表意數字一, 二, 三...
hiragana日文平假名あ, い, う...
hiragana-iroha平假名伊呂波順い, ろ, は...
katakana日文片假名ア, イ, ウ...
katakana-iroha片假名伊呂波順イ, ロ, ハ...
lower-greek希臘小寫字母α, β, γ...
hebrew希伯來數字א, ב, ג...

CSS3 新增關鍵字(現代瀏覽器支援良好)

關鍵字說明
decimal-leading-zero01, 02, 03...
cjk-decimal中日韓十進制數字
lower-alpha / upper-alpha標準化別名(同 lower-latin/upper-latin)
ethiopic-numeric衣索比亞數字系統
japanese-formal日文正式數字(壹、貳、參)
korean-hangul-formal韓文正式數字
simp-chinese-formal簡體中文正式數字
trad-chinese-formal繁體中文正式數字(壹、貳、參)
simp-chinese-informal簡體中文非正式(一、二、三)
trad-chinese-informal繁體中文非正式

自訂計數器:突破預設關鍵字限制

使用 counter-reset、counter-increment、content: counter(name) 實現任意編號格式。

範例:中文括號編號 (一)、(二)...

ol.chinese-paren {
  list-style: none;
  counter-reset: item;
}
ol.chinese-paren li::before {
  counter-increment: item;
  content: "(" counter(item, trad-chinese-informal) ") ";
  /* 需瀏覽器支援 trad-chinese-informal,否則用自定映射 */
}

範例:多層級編號 1.1, 1.2, 2.1...

ol.multi {
  list-style: none;
  counter-reset: level1;
}
ol.multi > li {
  counter-increment: level1;
}
ol.multi > li::before {
  content: counter(level1) ". ";
}
ol.multi ol {
  counter-reset: level2;
}
ol.multi ol li::before {
  counter-increment: level2;
  content: counter(level1) "." counter(level2) " ";
}

list-style 簡寫屬性

list-style: type position image;
/* 例 */
ul { list-style: disc inside none; }
ol { list-style: decimal outside url(bullet.svg); }
  • position:outside(預設,標記在內容外)、inside(標記在內容流內)。
  • image:優先於 type。

實戰建議

  • 重置預設:ul, ol { list-style: none; padding-left: 1.5rem; } 統一由設計系統控制。
  • 導航選單、麵包屑、標籤雲等非語意列表一律 list-style: none。
  • 有序列表語意明確時(步驟、排名),保留 decimal 或自訂計數器。
  • 國際化專案:根據 lang 屬性動態切換 list-style-type(如中文用 cjk-decimal、日文用 japanese-formal)。

總結

list-style-type 提供豐富的預設標記風格,涵蓋拉丁、希臘、西里爾、中日韓、希伯來、亞美尼亞、喬治亞、衣索比亞等文字系統。現代開發多搭配 list-style: none + ::before + CSS 計數器 / SVG 圖示,實現完全可控、可設計、可無障礙的列表視覺系統。

copyright © 萬盛學電腦網 all rights reserved