CSSだけで要素に自動連番

Ads

Result


ulのように自動で連番が付くやつです。li以外でも実装可能です

css

.foo div:before{
counter-increment:bar;
content:"第" counters(bar,"")"番目";
margin-right:20px;
}
<h3>html</h3>
<div class="foo">
<div>lorem ipsum</div>
<div>lorem ipsum</div>
<div>lorem ipsum</div>
<div>lorem ipsum</div>
<div>lorem ipsum</div>
<div>lorem ipsum</div>
</div>

ca i use

via

none