How to colour the list-style-type auto-generated numbers?

前端 未结 9 1252
遥遥无期
遥遥无期 2020-12-05 07:03

I\'m using the following list:

  1. This is the first footnote...
  2. &
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 07:32

    There is a way in CSS3, using the Generated and Replaced Content Module. With this technique you don't have do add any extra mark-up to your HTML. Something like this should do the trick:

    ol li {
        list-style-type: none;
        counter-increment: list;
        position: relative;
    }
    
    ol li:after {
        content: counter(list) ".";
        position: absolute;
        left: -2.5em;
        width: 2em;
        text-align: right;
        color: red;
    }
    

提交回复
热议问题