如何创建具有自定义起点和顺序的 html 列表,就像我将应用子列表一样,如下面的代码片段(但隐藏外部列表的编号)。
结果应该是这样的
1.1 Item
1.2 Item
1.3 Item
或
2.1 Item
2.2 Item
2.3 Item
取决于起点。
ol {
counter-reset: section;
list-style-type: none;
}
li::before {
counter-increment: section;
content: counters(section, ".") " ";
}
<ol start="2">
<li>
<ol>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ol>
</li>
</ol>
你是说这个吗?
ol {
counter-reset : section;
list-style-type : none;
}
ol li::before {
counter-increment : section;
content : var(--start) counter(section) ' ';
}
<ol style="--start: '2.';">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ol>