[英]Custom Ordered List Content
我希望模仿我在立法法規中看到的有序列表格式。 一個特點是有時您會看到如下列表:
(a) yadda
(b) yadda
(b-1) yadda
(b-2) yadda
(c) yadda
(d) yadda
您可以使用偽元素::before
和CSS計數器
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>
要在HTML中創建一個有序列表,您必須使用標簽<ol>
來指定一個有序列表,並且每個項目都應為<li>
“列表項”。
<ol>
<li>yadda</li>
<li>yadda</li>
<li>
<ol>
<li>yadda</li>
<li>yadda</li>
</ol>
</li>
<li>yadda</li>
</ol>
請在此處查看示例:
https://jsfiddle.net/jruizx/pcs2mh4j/
您可以看一下這個問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.