nth-child最后一个元素不生效

243 阅读1分钟
<div>
<p class="str">xxxx</p>
<p class="str">xxxx</p>
<p class="str">xxxx</p> 
<p class="str">xxxx</p>
<span>222</span>
</div>

想要改变最后一个str元素样式 因为后面还有span 所以用last-child不生效 用 last-of-typ

.actionmargin:not(:last-of-type){ //简写 其他都有margin-bottom: 18px; 最后一个不会生效
margin-bottom: 18px; 
// &:last-of-type{
// margin-bottom: 0; 
// }
}
.actionmargin{
margin-bottom: 18px; 
 &:last-of-type{
 margin-bottom: 0; 
 }
}

www.jianshu.com/p/622c96b09…