I'm working on a webpage where each item is represented by a bootstrap card. In my template, I use a loop to create cards for each item. However, I'm facing an issue - how can I restrict the number of cards displayed in a single row before moving on to the next one?
<div class = 'card-group'>
{% for plant in plant%}
{% if plant.available%}
<div class="card text-white bg-dark mb-3" style=''>
<img style='height: auto; max-width: 100%;' src="{{plant.thumbnail}}" alt="...">
<div class="container">
<h4 style='color:white;' class="card-title"><b>{{plant.name |title}}</b></h4>
<p style='font-size: 20px'>Soil: {{plant.soil |title}}</p>
<p style='font-size: 20px'>Price per unit: £{{plant.price |title}}</p>
</div>
<div class='button-section'>
<button class="order-button"><a href=''>Order Online</a></button>
</div>
</div>
{% endif %}
{% endfor %}
</div>
The current CSS styling for the cards is as follows:
.card {
margin: 10px;
display: flex;
}
.card-group {
justify-content: space-evenly;
}
(card title styles...)
.card-body {
text-align: left;
}
(card button styles...)
My goal is to have only four items displayed per row, and then move on to the next row with the rest of the items. Any suggestions on how to achieve this layout?