css如何给li标签前添加数字

Author: 陌小雨Date: 2020-09-03View: 64

wordpress网址导航主题wpsite-p用到了这个办法,可以使li标签前添加逐渐增加的数字,1、2、3、4、5这样子分线给大家:

.head_new ul{counter-reset:sectioncounter;}
.head_new ul li:before {
    display: inline-block;
    content: counter(sectioncounter);
    counter-increment: sectioncounter;
    width: 24px;
    height: 24px;
    text-align: center;
    line-height: 24px;
    border-radius: 50%;
    margin-right: 1em;
    background: #5bc648;
    color: #efe;
    font-size: 14px;
}

效果:wpsite-p网址导航主题