I'm designing a website w开发者_如何转开发ith divs with the following fashion:
<div id="showcase">
<div class="project"> <!-- this is the first row -->
<div class="project"> <!-- this is the first row -->
<div class="project"> <!-- this is the first row -->
<div class="project"> <!-- this is the second row -->
<div class="project"> <!-- this is the second row -->
<div class="project"> <!-- this is the second row -->
<div class="project"> <!-- this is the third row -->
<div class="project"> <!-- this is the third row -->
<div class="project"> <!-- this is the third row -->
</div>
</div>
I want to remove right margin to the "last" div of a row (each row has 3 divs).
Any suggestions to accomplish this?
I think you want the nth-child
selector:
$('#showcase .project:nth-child(3n)').addClass('margin-adjuster');
Here's a quick demo that just does a color change to show you how it works:
http://jsfiddle.net/ambiguous/YDvGw/
You could do a .css({ marginRight: 0 })
if you just wanted to change the margin without messing around with another class.
精彩评论