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

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

I\'m using the following list:

  1. This is the first footnote...
  2. &
9条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 07:46

    Combining some of the other answers, which I found to be incomplete, I find this most complete. It considers sub style-types for different levels in the hierarchy and considers that an li may be more than one line (:after places at bottom line, so we use :before).

    Note customizing of side character as well: 1. 1).Tested in Chrome.

    ol { counter-reset:li; }
    ol li {
        list-style-type:none;
        counter-increment:li;
        position:relative;
    }
    ol li:before {
        content:counter(li) ")";
        position:absolute;
        left: -2.6em;
        width: 2em;
        text-align: right;
        color: #f00;
    }
    ol ol li:before { content:counter(li,lower-alpha) ")"; }
    ol ol ol li:before { content:counter(li,lower-roman) "."; }
    

提交回复
热议问题