Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS-Selector :child(> n)?

I got the problem that I got a variable amount of child-elements. My :last-child :first-child rules should only apply, when there are at least 3 children

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

like image 433
user828591 Avatar asked Apr 25 '12 13:04

user828591


1 Answers

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

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

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

like image 96
Rob W Avatar answered Oct 20 '22 17:10

Rob W