css样式: 去除最后一个子元素的伪元素

其含义也为不给最后一个子元素添加伪元素

.item {
        height: 100%;
        text-align: center;
        flex: 1;
        position: relative;
        &:not(:last-child)::after {
            content: '';
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 1px;
            height: 21px;
            background-color: #00C5C9;
          }
        }

 :not 为css里面 的意思,就是不给他加样式 :not(:last-child) 意思为不给最后一个子元素加样式, 常用场景如下图,最后一个子元素缺少一个右竖线样式。


版权声明:本文为qq_39404437原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。