Can you count a particular class with CSS?

后端 未结 7 1078
刺人心
刺人心 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:41

    Here you go:

    https://jsfiddle.net/Cheese1991/qnmhvvxj/

    HTML:

    • One
    • Two
    • Three
    • Four

    CSS:

    ul {
        counter-reset:yourCounter;
        list-style:none;
    }
    ul li:not(.skip) {
        counter-increment:yourCounter;
        list-style:none;
    }
    ul li:not(.skip):before {
        content:counter(yourCounter) ". ";
    }
    ul li.skip:before {
        content:"\a0\a0\a0";
    }

    I hope this will help you

提交回复
热议问题