我们可以检索li的默认计数器值吗? [英] Can we retrieve the default counter value of an li?

查看:69
本文介绍了我们可以检索li的默认计数器值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在 CSS 中检索li的默认计数器值吗?


例如:

如果我有6 < li> ,分隔在2 < ol> ,但我想要< li> 从1到6,而不是1到3两次。我在第二个的< li> 上使用 value =4 ; ol> ,所以它工作,但现在,因为我使用

Can we retrieve in CSS the default counter value of an li?

For example:
If I have 6 <li>, separated in 2 <ol>, but I want the <li> to be listed from 1 to 6, not 1 to 3 twice. I used value="4" on the first <li> of the second <ol>, so it worked, but now since I'm using

ol {
  counter-reset: i 0;
}

ol li:before {
    content: counter(i);    
    counter-increment: i;
    font-weight: bold;
}​

content:counter(i); 上的 / code>不会计入 value =4第二个< ol>

我可以做些什么吗?

查看 JsFiddle

推荐答案

这是否适合你的需要? 在JSFiddle上查看

Does this suit your needs? View on JSFiddle

<ol>
  <li>test</li>
  <li>test</li>
  <li>test</li>
</ol>
<ol>
  <li>test</li>
  <li>test</li>
  <li>test</li>
</ol>



CSS



CSS

ol:first-of-type {
  counter-reset: i 0;
}

ol li:before {
  content: counter(i);    
  counter-increment: i;
  font-weight: bold;
}​

这篇关于我们可以检索li的默认计数器值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆