场景:比如多个div只有最后一个没有下边框

可以使用:last-child或者:last-of-type

区别:

CSS伪类 :last-child 表示其父元素的最后一个子元素。

CSS伪类:last-of-type其父元素下的最后一个指定类型的元素。

有时候设置最后一个用:last-child不生效,那么使用:last-of-type肯定就会生效了

 .items-wrap {
    width: 100%;
    background: linear-gradient(180deg, #e2eeff 0%, #ffffff 100%);
    border: 1px solid;
    &:last-of-type {
      border-bottom: none;
    }
  }

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐