[英]Custom Ordered List Content
I'm hoping to mimic the ordered list formatting that I see in legislative statutes. 我希望模仿我在立法法规中看到的有序列表格式。 One peculiarity is that you will sometimes see list such as this:
一个特点是有时您会看到如下列表:
(a) yadda
(b) yadda
(b-1) yadda
(b-2) yadda
(c) yadda
(d) yadda
you can use pseudo-element ::before
and CSS counters 您可以使用伪元素
::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>
To create an ordered list in HTML you have to use the tags <ol>
to specified a ordered list and every item should be a <li>
"list item". 要在HTML中创建一个有序列表,您必须使用标签
<ol>
来指定一个有序列表,并且每个项目都应为<li>
“列表项”。
<ol>
<li>yadda</li>
<li>yadda</li>
<li>
<ol>
<li>yadda</li>
<li>yadda</li>
</ol>
</li>
<li>yadda</li>
</ol>
Please see an example here: 请在此处查看示例:
https://jsfiddle.net/jruizx/pcs2mh4j/ https://jsfiddle.net/jruizx/pcs2mh4j/
You can have a look at this question: 您可以看一下这个问题:
Can ordered list produce result that looks like 1.1, 1.2, 1.3 (instead of just 1, 2, 3, ...) with css? 有序列表可以使用CSS生成看起来像1.1、1.2、1.3(而不只是1,2,3,...)的结果吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.