开发者

CSS selector for other than the first child and last child

开发者 https://www.devze.com 2023-04-13 05:04 出处:网络
I am making a very advanced website. My question: Is it possible to select all the other children except for the :first-child and the :last-child? I know there is a :not() selector but it doesn\'t wor

I am making a very advanced website. My question: Is it possible to select all the other children except for the :first-child and the :last-child? I know there is a :not() selector but it doesn't work with more than on开发者_JS百科e not in the parentheses. This is what I have:

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


Try:

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


Sure it will work, you just have to use two 'not' selectors.

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

It will continue down the line after the first one, saying "not the first child" and "not the last child".

0

精彩评论

暂无评论...
验证码 换一张
取 消