我正在尝试制作一个列表
元素1.鸟
元素2.狮子
...
问题是我不想为每个元素都写“元素”。有什么方法可以将内容添加到我的列表中吗?
最佳答案
你需要CSS counters :
#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;
}
<ol id="customlist">
<li>Elephant</li>
<li>Bird</li>
<li>Lion</li>
</ol>
关于html - 在列表前添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9258070/