0

我想排除 th 的最后一个和倒数第二个孩子来应用一些 css 属性。单独完成就像

.List  thead tr th:not(:last-child){
  //Some Css properties 
 }

倒数第二个孩子也一样。可以在一个 CSS 选择器中使用 not 运算符组合吗?

4

2 回答 2

4

CSS3 为我们带来了:nth-last-child()选择器。要组合多个:not项目,只需将它们添加到末尾。

JSFiddle

li:not(:last-child):not(:nth-last-child(2)) {
    color:red;
}

根据caniuse.com的说法,这种方法可能只有 IE9 才完全支持。我说可能是因为 caniuse 不够具体。就个人而言,除非有必要,否则我不会竭尽全力支持 < IE9。

于 2013-02-26T11:59:06.013 回答
0
.List thead tr th:nth-last-of-type(1) ,.List thead tr th:nth-last-of-type(2) {
/*Some Code*/
}

尝试这个

于 2013-02-26T12:00:08.493 回答