开发者

How to make css counter works with css selector?

开发者 https://www.devze.com 2023-03-29 12:22 出处:网络
I\'was trying to use css counter... This is my css code: div.primaries div.entries>div.meaning:first-child:before {

I'was trying to use css counter... This is my css code:

div.primaries div.entries>div.meaning:first-child:before {
    counter-increment: section;
    content: counter(section);
}

and the part of html

<div class="primaries">
<div class="headword entries">
<div class="meaning terms">
<span class="meaning terms text">A collection of items of the ...</span>
</div>
<div class="meaning entries">
<div class="example terms">
<span class="example terms text">an arms <em>cache</em></span>
</div>
</div>
<div class="meaning entries">
<div class="example terms">
<span class="example terms text">a <em>cache</em> of gold coins</span>
</div>
</div>
</div>开发者_运维知识库
<div class="headword entries">
<div class="meaning terms">
<span class="meaning terms text">A hidden or inaccessible ...</span>
</div>
</div>
<div class="headword entries">
<div class="meaning terms">
<span class="meaning terms text">An auxiliary memory from ...</span>
</div>
</div>
</div>

I did not use any "counter-reset". However, every number outputed was 1. So, why it is always 1?


Add this and I think it will do as you will:

div.primaries
{
  counter-reset: section;
}

See it work at jsfiddle/Larry/ev758/.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号