list-style 是 list-style-type、list-style-position、list-style-image 三個屬性的簡寫屬性,僅作用於 display: list-item 元素(如 `
/* 關鍵字 */
list-style-image: none; /* 預設,無圖標 */
list-style-image: url('icon.png'); /* 使用圖片,支援相對/絕對路徑 */
/* 若圖片載入失敗或為 none,回退到 list-style-type */
list-style-position: outside; /* 預設:標記在內容外側,文字環繞不對齊標記 */
list-style-position: inside; /* 標記在內容內側,文字按標記對齊 */
/* 注意:若 margin-left: 0,標記可能不顯示;建議 ≥ 30px */
| 值 | 效果 | CSS 級別 |
|---|---|---|
| disc | 實心圓 ● | CSS1 |
| circle | 空心圓 ○ | CSS1 |
| square | 實心方塊 ■ | CSS1 |
| decimal | 阿拉伯數字 1,2,3… | CSS1 |
| lower-roman | 小寫羅馬數字 i,ii,iii… | CSS1 |
| upper-roman | 大寫羅馬數字 I,II,III… | CSS1 |
| lower-alpha / lower-latin | 小寫字母 a,b,c… | CSS1/2 |
| upper-alpha / upper-latin | 大寫字母 A,B,C… | CSS1/2 |
| none | 無標記 | CSS1 |
| cjk-ideographic | 中文表意數字 一、二、三… | CSS2 |
| hiragana / hiragana-iroha | 日文平假名 | CSS2 |
| katakana / katakana-iroha | 日文片假名 | CSS2 |
| hebrew / armenian / georgian | 希伯來/亞美尼亞/喬治亞數字 | CSS2 |
/* 順序任意,缺省值用預設 */
list-style: square inside url('bullet.png');
list-style: lower-roman outside;
list-style: none; /* 清除所有標記 */
::marker 偽元素(現代瀏覽器支援)可單獨設定標記顏色、字體大小,無需圖片。ul, ol { list-style: none; padding-left: 0; } 統一起點。靈活組合三大子屬性,或直接使用簡寫,能輕鬆實現從經典項目符號到完全自定義的列表風格。