<div>
<p>paragraph</p>
<p>paragraph</p>
<p>paragraph</p>
</div>我想知道在css中我的目标是哪个孩子,这样我就可以这样做了:
div p:nth-child(n)::before{
content: n + ' ';
}输出结果将是
1个页面图
2分页图
3分页图
发布于 2020-01-03 23:55:02
只需在css中使用:
:root {
counter-reset: paragraph;
}
p:after {
content: counter(paragraph);
counter-increment: paragraph;
}发布于 2020-01-04 00:14:56
:root {
counter-reset: count;
}
p:before {
content: counter(count) '-';
counter-increment: count;
}<div>
<p>paragraph</p>
<p>paragraph</p>
<p>paragraph</p>
</div>
https://stackoverflow.com/questions/59581442
复制相似问题