Can you count a particular class with CSS?

后端 未结 7 1108
刺人心
刺人心 2021-02-02 08:08

Lets say I have a simple list like so:

  1. one
  2. two
  3. &l
7条回答
  •  忘掉有多难
    2021-02-02 08:35

    Giving display: block to the li elements without .count class is also working.

    ul {
        list-style-type:decimal;
        padding-left: 30px;
    }
    li:not(.count) {
        display: block;
    }
    

    Working Fiddle

    For older browsers:

    ul {
        list-style-type:decimal;
        padding-left: 30px;
    }
    li {
        display: block;
    }
    li.count {
        display: list-item;
    }
    

    Working Fiddle

    Another way, if you are planning to change the display state of all li elements, use :after/:before pseudo classes with display as list-item.

    Working Fiddle

提交回复
热议问题