I have an masonry isotope grid that has n number of rows with two column sizes: 160px by 160px and 320px by 320px and I'd like to assign different styles to the first and last element of each row. My rows could have anywhere from 4 elements to 7 elements. I've been struggling with this for a bit, and wondering if it's possible.
HTML
<div id="grid" style="position: relative; overflow: hidden; height: 960px;"
class="isotope">
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="two_by_two">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_two">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="two_by_two">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_two">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="two_by_two">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_two">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
<div class="one_by_one">
<img class="thumb" src="https://s3.amazonaws.com/stitch-images/products/gucci.png"
/>
</div>
</div>
CSS
#grid {
margin:auto;
margin-top:55px;
margin-bottom:200px;
width:1140px
}
#grid .thumb {
width:97%;
height:97%
}
#grid .one_by_one {
width:160px;
height:160px;
background:url(https://s3.amazonaws.com/stitch-images/assets/cell_1x1.png);
cursor:pointer
}
#grid .one_by_two {
width:160px;
height:320px;
background:url(https://s3.amazonaws.com/stitch-images/assets/cell_1x2.png);
cursor:pointer
}
#grid .two_by_two {
width:320px;
height:320px;
background:url(https://s3.amazonaws.com/stitch-images/assets/cell_2x2.png);
cursor:pointer
}
JS
$("#grid").isotope masonry: layoutMode: 'fitRows'
View my Jsfiddle http://jsfiddle.net/TDma4/