sandy
sandy

Reputation: 1155

How to exclude more than one th child

I want to exclude last and second last child of th to apply some css property.Individually it come be done like

.List  thead tr th:not(:last-child){
  //Some Css properties 
 }

and same for second last child.Can it be combined using not operator in one css selector?

Upvotes: 0

Views: 203

Answers (2)

Daniel Imms
Daniel Imms

Reputation: 50149

CSS3 brings us the :nth-last-child() selector. To combine multiple :not items just add them to the end.

JSFiddle

li:not(:last-child):not(:nth-last-child(2)) {
    color:red;
}

According to caniuse.com this method may be only fully supported from IE9. I say may be because caniuse isn't specific enough. Personally, I don't go out of my way to support < IE9 anymore unless it's a requirement.

Upvotes: 4

Sahil Popli
Sahil Popli

Reputation: 1995

.List thead tr th:nth-last-of-type(1) ,.List thead tr th:nth-last-of-type(2) {
/*Some Code*/
}

Try This

Upvotes: 0

Related Questions