| 屬性 | 值範例 | 說明 |
|---|---|---|
list-style-type | disc / circle / square / decimal / lower-roman / none | 項目符號樣式 |
list-style-position | outside (預設) / inside | 符號相對內容位置 |
list-style-image | url(bullet.png) / none | 自訂圖片符號 |
list-style/* 順序任意,建議 type → position → image */
ul {
list-style: square inside url(bullet.png);
/* 等同 */
list-style-type: square;
list-style-position: inside;
list-style-image: url(bullet.png);
}
ul, ol {
list-style: none; /* 移除符號 */
margin: 0; padding: 0; /* 移除縮進 */
}
.numbered {
list-style: none;
counter-reset: item;
}
.numbered li::before {
counter-increment: item;
content: counter(item) ". ";
font-weight: bold; color: #1976d2; margin-right: .5em;
}
支援巢狀編號:counter-reset: section; counter-increment: section; content: counters(section, ".") " ";
li {
list-style-image: url(bullet.svg);
/* 圖片預設垂直置中於行盒,若需精確對齊改用背景圖 */
background: url(bullet.svg) no-repeat left center / 1em;
padding-left: 1.5em;
list-style: none;
}
@media (max-width: 600px) {
.nav-list { display:flex; flex-wrap:wrap; gap:.5rem; list-style:none; padding:0; }
.nav-list li { flex:1 0 auto; }
}
::marker 偽元素 (直接樣式化符號):Chrome 86+、Firefox 68+、Safari 15+、Edge 86+