У меня есть изотопная сетка из кладки, у которой есть n рядов с двумя размерами столбцов: 160px на 160px и 320px на 320px, и я бы хотел назначить разные стили первому и последнему элементу каждой строки. Мои строки могут содержать от 4 элементов до 7 элементов. Я немного борется с этим и задаюсь вопросом, возможно ли это.
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'
Просмотреть мою Jsfiddle http://jsfiddle.net/TDma4/