Ekr*_*emG 4 html css html-lists pseudo-element
我想做一个像
Element 1 的列表.鸟
元素2.狮子
......
问题是我不想为每个项目写"元素".有没有办法在我的列表中添加内容?
你需要CSS计数器:
#customlist {
/* delete default counter */
list-style-type: none;
/* create custom counter and set it to 0 */
counter-reset: elementcounter;
}
#customlist>li:before {
/* print out "Element " followed by the current counter value */
content: "Element " counter(elementcounter) ": ";
/* increment counter */
counter-increment: elementcounter;
}Run Code Online (Sandbox Code Playgroud)
<ol id="customlist">
<li>Elephant</li>
<li>Bird</li>
<li>Lion</li>
</ol>Run Code Online (Sandbox Code Playgroud)