本文介绍了如何使用CSS选择器选择除第一个和最后一个以外的所有子代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何选择表中除第一个和最后一个孩子以外的所有孩子?我已经尝试过了,但是最终选择了所有不是第一个的孩子和所有不是最后一个的孩子,最后都是所有孩子:
How would I select all the children in a table except for the first and last? I've tried this, but it ends up selecting all children that aren't first and all children that aren't last, which ends up being all children:
table.programs tr td:not(:first-child), table.programs tr td:not(:last-child) { }我希望所有的孩子既不是第一个也不是最后一个.我该怎么办?
I want all children that are neither first nor last. How can I do this?
推荐答案使用两个组合的:not()选择器,从而引用与它们都匹配的元素,即,与两个选择器都不匹配的元素用作:
Use two :not() selectors combined, thereby referring to elements that match both of them, i.e. to elements that match neither of the selectors used as operands of :not():
table.programs td:not(:first-child):not(:last-child)更多推荐
如何使用CSS选择器选择除第一个和最后一个以外的所有子代
发布评论