css计数器的使用counter-increment

 




section {
display: flex;
100%;
background: blue;
counter-increment: row;
line-height: 50px;
}
section:before{
content:"第"counter(row)"行";
color:#fff;
}
section div{
counter-increment: ccc;
background: red;
color:#fff;
height:50px;
line-height: 50px;
50px;
text-align: center;
}

section div:before{
content:counter(ccc);
}




<section>
<div></div>
<div></div>
<div></div>
</section>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section><section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section><section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section><section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section><section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>


原文地址:https://www.cnblogs.com/yixiaoyang-/p/11738341.html