Dan*_*iel 95 html css css-selectors
我正在建立一个非常先进的网站.我的问题:是否可以选择除了:first-child和之外的所有其他孩子:last-child?我知道有一个:not()选择器,但它不适用于不在括号中的多个选择器.这就是我所拥有的:
#navigation ul li:not(:first-child, :last-child) {
background: url(images/UISegmentBarButtonmiddle@2x.png);
background-size: contain;
}
Run Code Online (Sandbox Code Playgroud)
Sal*_*bas 237
试试#navigation ul li:not(:first-child):not(:last-child).
ani*_*son 19
当然它会工作,你只需要使用两个'不'选择器.
#navigation ul li:not(:first-child):not(:last-child) {
Run Code Online (Sandbox Code Playgroud)
它将在第一个之后继续下线,说"不是第一个孩子"和"不是最后一个孩子".