要给元素加左边框,但是第一个不加
写法一:
ul {
display: flex;
justify-content: flex-end;
align-items: center;
height: 53px;
li {
a {
display: inline-block;
padding: 0 15px;
color: #cdcdcd;
line-height: 1;
// 全部加左边框
border-left: 2px solid #666;
i {
font-size: 14px;
margin-right: 2px;
}
}
// 单独设置第一个元素不加
&:nth-child(1) {
a {
border-left: 0;
}
}
}
}
方法二:(便捷)
ul {
display: flex;
justify-content: flex-end;
align-items: center;
height: 53px;
li {
a {
display: inline-block;
padding: 0 15px;
color: #cdcdcd;
line-height: 1;
i {
font-size: 14px;
margin-right: 2px;
}
}
// 除第一个元素外,其他元素都加左边框
~ li {
a {
border-left: 2px solid #666;
}
}
}
}