Making Bootstrap Cards of Equal Height in Card-Columns
In Bootstrap 4, the card-columns class is used to display cards in columns, but cards may vary in height depending on their content. To achieve equal height cards, we can use a combination of CSS and flexbox.
Solution:
Instead of setting a fixed minimum height on the cards, we can use the align-items-stretch utility on the column elements within the card-columns. This makes the columns stretch to the full height of the tallest card.
.card-columns .col { align-items: stretch; }
Implementation:
Wrap your card-columns within a container and each card within a column as follows:
<div class="container"> <div class="row"> <div class="col-lg-4 align-items-stretch"> <div class="card"> <!-- Card content --> </div> </div> <div class="col-lg-4 align-items-stretch"> <div class="card"> <!-- Card content --> </div> </div> <div class="col-lg-4 align-items-stretch"> <div class="card"> <!-- Card content --> </div> </div> </div> </div>
Note:
The above is the detailed content of How to Make Bootstrap 4 Card-Columns Cards of Equal Height?. For more information, please follow other related articles on the PHP Chinese website!