用于第一个子级和最后一个子级以外的其他子级的 CSS 选择器

我正在做一个非常先进的网站。我的问题是: 除了 :first-child:last-child,是否可以选择其他所有的孩子?我知道有一个 :not()选择器,但它不与一个以上的不在括号内的工作。这就是我所拥有的:

#navigation ul li:not(:first-child, :last-child) {
background: url(images/UISegmentBarButtonmiddle@2x.png);
background-size: contain;
}
93060 次浏览

试试:

#navigation ul li:not(:first-child):not(:last-child) {
...
}

当然它会工作,你只需要使用两个“非”选择器。

#navigation ul li:not(:first-child):not(:last-child) {

在第一个孩子之后,它还会继续下去,说“不是第一个孩子”和“不是最后一个孩子”。