Is there a way to restrict the css3 nth-of-type class? I have a dynamic number of section elements with different classes denoting their layout needs. I would like to get every third .module , but it seems that nth-of-type looking for the type of the element of the classes, and then evaluating the type. Instead, I would like to limit it to .module s only.
Thank!
JSFiddle to demonstrate: http://jsfiddle.net/danielredwood/e2BAq/1/
HTML:
<section class="featured video"> <h1>VIDEO</h1> </section> <section class="featured module"> <h1>NOT A VIDEO</h1> </section> <section class="featured module"> <h1>NOT A VIDEO</h1> </section> <section class="featured module"> <h1>NOT A VIDEO (3)</h1> </section> <section class="featured module"> <h1>NOT A VIDEO</h1> </section> <section class="featured module"> <h1>NOT A VIDEO</h1> </section> <section class="featured module"> <h1>NOT A VIDEO (6)</h1> </section>
CSS
.featured { width:31%; margin:0 0 20px 0; padding:0 3.5% 2em 0; float:left; background:#ccc; } .featured.module:nth-of-type(3n+3) { padding-right:0; background:red; } .featured.video { width:auto; padding:0 0 2em 0; float:none; }
css css-selectors css3 pseudo-class
technopeasant Jun 06 '12 at 20:33 2012-06-06 20:33
source share