CSS :not(:last-child):after selector

前端 未结 8 1825
时光取名叫无心
时光取名叫无心 2020-12-04 05:05

I have a list of elements, which are styled like this:

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 05:27

    If it's a problem with the not selector, you can set all of them and override the last one

    li:after
    {
      content: ' |';
    }
    li:last-child:after
    {
      content: '';
    }
    

    or if you can use before, no need for last-child

    li+li:before
    {
      content: '| ';
    }
    

提交回复
热议问题