Jac*_*Goh 5 html css css-counter
演示:https : //jsfiddle.net/jacobgoh101/uqrkaodc/3/
<ol>
<li>a</li>
</ol>
<ul>
<li>b</li>
</ul>
<ol>
<li>c</li>
<li>d</li>
<li>e</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
ol li {
counter-increment: list-0;
list-style: none;
}
ol li:before {
content: counter(list-0, decimal) '. ';
}
Run Code Online (Sandbox Code Playgroud)
当前结果
1 a
• b
1 c
2 d
3 e
Run Code Online (Sandbox Code Playgroud)
有没有办法在下面实现这个结果?
预期结果
1 a
• b
2 c
3 d
4 e
Run Code Online (Sandbox Code Playgroud)
(上下文:尝试使嵌套列表与 QuillJS 一起工作。https ://github.com/quilljs/quill/issues/979)
更新:
由于QuillJS库的限制,我不是真的能够添加start="2"到ol或更改HTML结构。
如果可能的话,我想我需要一个纯 CSS 解决方案。
ol {
list-style-type: none;
/* Remove default numbering */
}
ol > li:before {
counter-increment: mycounter;
content: counter(mycounter) ". ";
}
ol:first-of-type {
counter-reset: mycounter;
}Run Code Online (Sandbox Code Playgroud)
<ol>
<li>a</li>
</ol>
<ul>
<li>b</li>
</ul>
<ol>
<li>c</li>
<li>d</li>
<li>e</li>
</ol>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
372 次 |
| 最近记录: |