php - Use twitter bootstrap span in foreach -
how use twitter spans within foreach loop?
this code:
<div class="row-fluid"> <?foreach ($photos $photo) { ?> <div class="span4"> stuff </div> <? }?> </div>
but problem 4th output (which on 2nd row) off center - due margin/padding left.
i'm trying avoid having add counter , manually insert new 'row' after each 3rd loop - surely there cleaner way via bootstrap/css?
by using css3's nth-child selector, can target elements using math.
.span4:nth-child(3n+1) { /* css here */ }
the 3n+1 math function n incrementing 1, target elements #1 (3x0 + 1), #4 (3x1 + 1), #7 (3x2 + 1), etc.
Comments
Post a Comment