使用 :not() 来精简css代码

// 不使用:not()
.nav li {
    
    
  border-bottom: 1px solid #666;
}
.nav li:last-child {
    
    
  border-bottom: none;
}

// 使用:not()
.nav li:not(:last-child) {
    
    
  border-bottom: 1px solid #666;
}

// 或者使用兄弟选择符~
.nav li:first-child ~ li {
    
    
  border-bottom: 1px solid #666;
}

猜你喜欢

转载自blog.csdn.net/lannieZ/article/details/111469058