CSS3: how to select every 4th and 5th element

I am new to these selectors and I was wondering how I would do this.

My selector should select the 4th and 5th elements, but then he should continue to do this. Therefore, he will need to choose 4, 5, 9, 10, 14, 15, etc.

How is this possible? At the moment, I can select every third element as follows:

.pure-gr .pure-u-1-3:nth-child(3n+3) 

But I'm not sure how I can translate this into what I need.

Thanks for any help.

+7
css css-selectors css3
source share
2 answers

In fact, you want to select each pair from the 4th and 5th elements with jumps of 5.

So, use only two comma separated selectors.

 .pure-gr .pure-u-1-3:nth-child(5n + 4), .pure-gr .pure-u-1-3:nth-child(5n) 

jsFiddle Demo

Result

+6
source share

nth-child tester small page: http://css-tricks.com/examples/nth-child-tester/

 .pure-u-1-3:nth-child(5n + 4), .pure-u-1-3:nth-child(5n){ color:red; } 

http://css-tricks.com/useful-nth-child-recipies/

http://css-tricks.com/how-nth-child-works/

+1
source share

All Articles