如题,.card
绑定的元素是使用v-for
循环的列表(vue项目),如何不显示最后一条线?
尝试使用 &:not(:last-child)::after ,没成功。
.container {
.card {
position: relative;
width: auto;
margin: 25px 0 50px 0;
&::after {
content: '';
width: 886px;
height: 1px;
position: absolute;
bottom: -25px;
background-color: #DDDDDD;
}
}
}
新增部分如下:
与处理border-bottom
类似,最后一个.card
元素,margin-bottom
也需要单独设置不同的值。&:last-child
和 &:nth-last-child(1)
目前都没生效。
<div class="container">
<div class="card" v-for"xxx"> <!-- 循环列表 -->
列表...
</div>
</div>
.container {
.card {
margin: 25px 0 50px 0;
}
&:nth-last-child(1) {
margin: 25px 0 0 0;
}
}
其实很简单啊,只需要对最后一个元素的
:after
伪类处理一下就好了。