CSS selector: child (> n)?

I had a problem that I got a variable number of children. My: last-child: the rules of the first child should be applied only if there are at least 3 children

I tried: only-child, which can be overwritten: last- and: first-child, when there is only 1 child, but when I have 2 children, I have a problem. Is there some kind of selector that only applies when there are more children than n?

+3
source share
1 answer

Use the selector :nth-child(n+3)(where 3 is the youngest youngest child).

:last-child:nth-child(n+3) {
     /* Selects the last child which is at least the third child */
}

Demo: http://jsfiddle.net/vCZ9A/

+13
source

All Articles