以下两种情况:not()选择器均不生效
<div class="nav">
<div></div>
<div class="item"></div>
<div class="item"></div>
</div>
<style>
.nav .item:not(:first-child) {
margin-top: 20px;
}
</style>
:first-child 列表元素前面有元素不生效
<div class="nav">
<div class="item"></div>
<div class="item"></div>
<div></div>
</div>
<style>
.nav .item:not(:last-child) {
border-bottom: 1px solid #666;
}
</style>
:last-child 列表元素后面有元素不生效
解决:
将列表元素用div包起来
<div class="nav">
<div>
<div class="item"></div>
<div class="item"></div>
</div>
</div>