-2
I need to create a new div class="row" when it reaches the limit of 12 columns, in my case I am using col-md-3. Therefore, the maximum items per column are 4.
<?php foreach ($data['palettes'] as $row): ?>
<div class="row">
<div class="col-md-3">
<div class="view-palette shadow p-3 mb-5 rounded clearfix">
<div class="palette">
<div class="spot color-1" style="background-color: #<?=$row->color1?> !important;"></div>
<div class="spot color-2" style="background-color: #<?=$row->color2?> !important;"></div>
<div class="spot color-3" style="background-color: #<?=$row->color3?> !important;"></div>
<div class="spot color-4" style="background-color: #<?=$row->color4?> !important;"></div>
</div>
<div class="float-left mt-3">
<a href="#" class="btn btn-light btn-sm">
<i class="fas fa-heart"></i> 0
</a>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
The variable $data is only receiving data from the bank return $this->db->select("SELECT * FROM palettes");
Only that way I did, you’re creating a .row for each result that is coming from the database. How do I solve this ?
And if you remove the
divwith classrowloop and useflexbox? In case I would create adivout of the loop with the properties:display: flex; flex-wrap: wrap;– Pedro Henrique
And the columns would look like? I’m still learning :(
– Max Fly
Keeping the
col-md-3in the item, theflexboxwill automatically organize without the need ofclass row– Pedro Henrique