gpt4 book ai didi

css - 如何排除一个以上的 child

转载 作者:太空宇宙 更新时间:2023-11-03 21:54:14 24 4
gpt4 key购买 nike

我想排除 th 的最后一个和倒数第二个 child 以应用一些 css 属性。单独地它会像

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

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

最佳答案

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

JSFiddle

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

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

关于css - 如何排除一个以上的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15088514/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com