2016-04-22 91 views
0

我希望能夠模仿我在立法法規中看到的有序列表格式。一個特點是,有時你會看到名單像這樣:自定義順序列表內容

(a) yadda 
(b) yadda 
(b-1) yadda 
(b-2) yadda 
(c) yadda 
(d) yadda 
+0

有什麼問題,你嘗試過什麼? –

回答

1

你可以使用僞元素::beforeCSS counters

ul { 
 
    counter-reset: list, list2, list3; 
 
} 
 
li { 
 
    list-style: none; 
 
    counter-increment: list; 
 
} 
 
li::before { 
 
    content: "(" counter(list, lower-alpha)")"; 
 
    position: relative; 
 
    left: -5px 
 
} 
 
li:nth-child(3) { 
 
    counter-increment: list2 2 
 
} 
 
li:nth-last-child(2) { 
 
    counter-increment: list3 3 
 
} 
 

 
li:nth-child(3)::before { 
 
    content: "(" counter(list2, lower-alpha)"-1)"; 
 
} 
 
li:nth-child(4)::before { 
 
    content: "(" counter(list2, lower-alpha)"-2)"; 
 
}
<ul> 
 
    <li>Some text here</li> 
 
    <li>Some more text here..</li> 
 
    <li>Oh yeah, here's some pretty text</li> 
 
    <li>Some text here</li> 
 
    <li>Some more text here..</li> 
 
    <li>Oh yeah, here's some pretty text</li> 
 
</ul>