:before 和 :after选择器 经常跟CSS计数器特性一起使用。
1.counter-reset 属性为计数器设置名称;
counter-reset:paracount;
counter-reset:paracount 10;//初始为10
counter-reset:paracount 10 othercounter;
2.counter在:before 或者 :after 的content中使用。
content:counter(paracount)“_”;
content:counter(paracount,lower-alpha);
3.counter-increment属性专门用来设置计数器增量;
counter-increment:paracount;
paracount 的默认值是1;
counter-increment:paracount 2;//初始增量设为2
body{ counter-reset: paracount; } p:before{ content: counter(paracount)"."; counter-increment: paracount; }