Juicy
Juicy

Reputation: 12520

Select all but first two divs

I can use the following to select all divs that are not the first div among their siblings.

div:not(:nth-of-type(1))

Is there anyway I can select all div's that are not the first two?

Upvotes: 0

Views: 3042

Answers (3)

Danillo Felixdaal
Danillo Felixdaal

Reputation: 585

It can even be dome more clear, without specifically writing out the not pseudo selector per element.

U can do this the get the same results:

:not(:nth-of-type(-n+2)) {

}

:not(:nth-child(-n+2)) {

}

I know its a late answer:P but maybe still usefull to somebody

Upvotes: 1

aniskhan001
aniskhan001

Reputation: 8521

You can use multiple :not to exclude multiple items

Example

div:not(:nth-child(1)):not(:nth-child(2)) {
    background: blue;
}

DEMO

Upvotes: 1

LcSalazar
LcSalazar

Reputation: 16831

You can use sequential :not pseudos, so: div:not(:nth-of-type(1)):not(:nth-of-type(2))

http://jsfiddle.net/akm4qnds/

OR

Even better, you can use sibilings selectors... Like div:condition ~ div that will select every sibiling divs that are after the one with the condition.

So: div:nth-of-type(2) ~ div will select every div that comes after the second child.

http://jsfiddle.net/akm4qnds/1/

Upvotes: 2

Related Questions