html自动编号列表,html – 如何开始一个新的列表,从上一个列表继续编号?

我试图做一些以前很容易在开始属性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; }

  1. You can't touch this
  2. You can't touch this

STOP! Hammer time.

  1. 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; }

  1. You can't touch this
  2. You can't touch this

STOP! Hammer time.

  1. You can't touch this

注意:事实证明,这个“解决方案”不工作在IE8的兼容性视图(也可能是其他版本/浏览器)。如果这不打扰你,伟大的。 🙂

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值