| 關鍵字 | 渲染 | 適用場景 |
|---|---|---|
disc | ● 實心圓 | 無序列表默認 |
circle | ○ 空心圓 | 二級無序列表 |
square | ■ 實心方塊 | 三級無序列表 |
decimal | 1, 2, 3… | 有序列表默認 |
decimal-leading-zero | 01, 02, 03… | 固定寬度編號 |
lower-roman | i, ii, iii, iv… | 附錄、法律條文 |
upper-roman | I, II, III, IV… | 大綱一級 |
lower-alpha / lower-latin | a, b, c, d… | 子條款 |
upper-alpha / upper-latin | A, B, C, D… | 大綱次級 |
none | 無標記 | 導航、面包屑、重置 |
| 關鍵字 | 文字系統 | 示例 | 支持度 |
|---|---|---|---|
cjk-ideographic | 中日韓表意數字 | 一、二、三、四 | Chrome/Edge/Firefox/Safari ✅ |
hiragana | 日文平假名 | あ、い、う、え | 主流 ✅ |
katakana | 日文片假名 | ア、イ、ウ、エ | 主流 ✅ |
hiragana-iroha | 伊呂波順平假名 | い、ろ、は、に | 主流 ✅ |
katakana-iroha | 伊呂波順片假名 | イ、ロ、ハ、ニ | 主流 ✅ |
lower-greek | 希臘小寫字母 | α, β, γ, δ | 主流 ✅ |
armenian | 亞美尼亞數字 | Ա, Բ, Գ | Firefox/Safari ✅, Chrome ⚠️ |
georgian | 喬治亞數字 | ა, ბ, გ | Firefox/Safari ✅, Chrome ⚠️ |
hebrew | 希伯來數字 | א, ב, ג | Firefox/Safari ✅, Chrome ⚠️ |
ul { list-style-image: url(bullet.svg); }
缺點:無法縮放定位、高密度屏模糊、無法動畫。
/* 修改標記顏色、大小、內容 */
li::marker {
color: #007bff;
font-size: 1.2em;
content: "▸ "; /* 自定義字符 */
}
/* 數字編號加括號 */
ol li::marker { content: counter(list-item) ") "; }
/* 針對特定列表 */
.nav li::marker { content: ""; } /* 隱藏導航標記 */
支持:Chrome 86+, Firefox 68+, Safari 15+, Edge 86+。
.numbered {
counter-reset: section; /* 重置計數器 */
}
.numbered li {
position: relative;
padding-left: 2em;
list-style: none;
}
.numbered li::before {
counter-increment: section;
content: counter(section) ".";
position: absolute;
left: 0;
color: #007bff;
font-weight: 600;
}
/* 多級嵌套編號 1.1, 1.2 */
.nested { counter-reset: subsection; }
.nested li { counter-increment: subsection; }
.nested li::before {
content: counters(section, ".") "." counters(subsection, ".") " ";
}
ul { list-style-position: outside; } /* 默認:標記在內邊距外,文字不環繞 */
ul { list-style-position: inside; } /* 標記在內容流內,文字環繞對齊 */
ul { list-style: square inside url(bullet.svg); }
/* 順序:type || position || image */
<ul>/<ol>/<li> 語義標簽,而非 <div> 模擬。list-style: none 而非 display: none。<ul><li>...<ul><li>...</ul></li></ul>。counter 而非硬編碼數字。::marker 樣式不影響螢幕閱讀器播報。/* 面包屑 — 無標記、行內分隔符 */
.breadcrumb { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; }
.breadcrumb li+li::before { content: "/"; color: #999; }
.breadcrumb li[aria-current="page"] { color: #333; font-weight: 600; }
/* 分頁 — 數字+箭頭 */
.pagination { display: flex; gap: .25rem; list-style: none; }
.pagination a { padding: .25rem .5rem; border: 1px solid #ddd; border-radius: 4px; }
.pagination [aria-current="page"] { background: #007bff; color: #fff; border-color: #007bff; }
/* 時間軸 — 計數器+偽元素連線 */
.timeline { position: relative; padding-left: 2rem; list-style: none; }
.timeline::before { content: ""; position: absolute; left: .75rem; top: 0; bottom: 0; width: 2px; background: #ddd; }
.timeline li { position: relative; padding-bottom: 2rem; }
.timeline li::before {
counter-increment: step;
content: counter(step);
position: absolute; left: -2rem; width: 1.5rem; height: 1.5rem;
border-radius: 50%; background: #007bff; color: #fff;
display: flex; align-items: center; justify-content: center;
}
列表樣式控制已從屬性配置進化為偽元素/計數器編程。掌握 ::marker 與 counter,讓列表不再只是「項目符號」,而是信息架構的視覺化表達。