html实现目录序号,使用CSS3自动实现文章标题级别(自动目录 | 自动序号)

CSS

语言:

CSSSCSS

确定

.counter {

counter-reset: index-1;

}

.counter-index-1 {

counter-increment: index-1;

counter-reset: index-2;

}

.counter-index-1::before {

content: counter(index-1)'.';

}

.counter-index-2 {

counter-increment: index-2;

counter-reset: index-3;

}

.counter-index-2::before {

content: counter(index-1)'.'counter(index-2)'.';

}

.counter-index-3 {

counter-increment: index-3;

counter-reset: index-4;

}

.counter-index-3::before {

content: counter(index-1)'.'counter(index-2)'.'counter(index-3)'.';

}

.counter-index-4 {

counter-increment: index-4;

counter-reset: index-5;

}

.counter-index-4::before {

content: counter(index-1)'.'counter(index-2)'.'counter(index-3)'.'counter(index-4)'.';

}

.counter-index-5 {

counter-increment: index-5;

counter-reset: index-6;

}

.counter-index-5::before {

content: counter(index-1)'.'counter(index-2)'.'counter(index-3)'.'counter(index-4)'.'counter(index-5)'.';

}

.counter-index-6 {

counter-increment: index-6;

counter-reset: index-7;

}

.counter-index-6::before {

content: counter(index-1)'.'counter(index-2)'.'counter(index-3)'.'counter(index-4)'.'counter(index-5)'.'counter(index-6)'.';

}

.counter-index-1,

.counter-index-2,

.counter-index-3,

.counter-index-4,

.counter-index-5,

.counter-index-6 {

position: relative;

}

.counter-index-1::before,

.counter-index-2::before,

.counter-index-3::before,

.counter-index-4::before,

.counter-index-5::before,

.counter-index-6::before {

margin-right: .5em;

position: absolute;

right: 100%;

}

html {

font-family: sans-serif;

color: #111;

}

.counter {

max-width: 400px;

margin: auto;

padding: 40px 70px;

}

.counter-index-1 {

color: #2b2b2b;

}

.counter-index-2 {

color: #444444;

}

.counter-index-3 {

color: #5e5e5e;

}

.counter-index-4 {

color: #777777;

}

.counter-index-5 {

color: #919191;

}

.counter-index-6 {

color: #aaaaaa;

}

p {

font-size: .9rem;

line-height: 1.4;

}

code {

background: #eee;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值