我试图做一些以前很容易在开始属性ol标签被废弃。我只是想在我的页面中有一对有序列表,但开始第二个列表的编号,第一个完成。就像是:
1. do stuff
2. do stuff
Here's a paragraph
3. do stuff
我已经看到counter-reset和counter-increment CSS属性应该能够实现这一点,但我不能得到它的工作。这里是我的代码到目前为止:
ol li { counter-increment: mycounter; }
ol.start { counter-reset: mycounter; }
ol.continue { counter-reset: mycounter 2; }
- You can't touch this
- You can't touch this
STOP! Hammer time.
- You can't touch this
说实话,即使这个工作,它不会是理想的。我不想在我的ol.continue选择器中指定第一个列表达到的数量。
我究竟做错了什么?什么是最小的HTML / CSS组合需要达到所需的效果?
提前致谢… :)
我终于采纳了解决方案
这里是我最后使用的HTML和CSS代码。感谢Felix让我在那里。还必须提到,李提供了一个有趣的jQuery的替代品。
ol.split { list-style-type: none; }
ol.split li:before
{
counter-increment: mycounter;
content: counter(mycounter) ".\00A0\00A0";
}
ol.split li
{
text-indent: -1.3em;
}
ol.start { counter-reset: mycounter; }
- You can't touch this
- You can't touch this
STOP! Hammer time.
- You can't touch this
注意:事实证明,这个“解决方案”不工作在IE8的兼容性视图(也可能是其他版本/浏览器)。如果这不打扰你,伟大的。 🙂