好吧,我会塌陷.这是我的解决方案
.some-class div {
background: blue;
}
.some-class div:first-child:last-child {
background: red;
}
The background of this should be red.
The background of this should be blue.
The background of this should be blue
编辑
显然,还有通过调查@LiorRaz’s comment找到的:only-child选择器
值得至少研究一下.这是一个嵌入式示例.
.some-class div {
background: blue
}
.some-class div:only-child {
background: red;
}
The background of this should be red.
The background of this should be blue.
The background of this should be blue