php - Bootstrap row element based on breakpoint -


i'm using bootstrap , looping div - because bootstrap requires parent div 'row' class, need print row based on number of divs within that. problem is, examples can find set number, , need based on breakpoint. example, code is:

<div class="row">      <?php foreach($projects $project): ?>        <div class="col-lg-4 col-md-6 col-sm-12 project_box">          <a href="<?= $project->url() ?>" class="project_name"><?= $project->title()->html() ?></a>            <?php if($image = $project->images()->sortby('sort', 'asc')->first()): $thumb = $image->crop(600, 600); ?>              <a href="<?= $project->url() ?>"><img src="<?= $thumb->url() ?>" alt="thumbnail <?= $project->title()->html() ?>" class="responsive" /></a>            <?php endif ?>            <p class="summary">              <?php echo excerpt($project->problem(), 200) ?>            </p>          </a>          <a href="<?= $project->url() ?>" class="btn project">read more</a>      </div>      <?php endforeach ?>    </div>

as can see, child div in question needs wrapped 'col-lg-4 col-md-6 col-sm-12' meaning on large devices row parent should printed every 3 divs, on medium every 2 , on small , small every 1.

are there ideas or examples on this? such hard thing google , i'm out of ideas. thanks!

you don't need "print" row every x cols. put of cols in single .row.

<div class="row">     <div class="col-lg-4 col-md-6 col-sm-12 project_box">..</div>     <div class="col-lg-4 col-md-6 col-sm-12 project_box">..</div>     <div class="col-lg-4 col-md-6 col-sm-12 project_box">..</div>     <div class="col-lg-4 col-md-6 col-sm-12 project_box">..</div>     <div class="col-lg-4 col-md-6 col-sm-12 project_box">..</div>     ... </div> 

this known column wrapping.

however, if content of each col varies in height, need use "clearfix" responsive resets every x cols, or make columns same height. otherwise you'll have the height problem.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -