Home > Web Front-end > CSS Tutorial > How to Make Bootstrap 4 Cards Equal Height in Columns?

How to Make Bootstrap 4 Cards Equal Height in Columns?

Barbara Streisand
Release: 2024-10-29 19:01:30
Original
408 people have browsed it

How to Make Bootstrap 4 Cards Equal Height in Columns?

Bootstrap 4 - Making Cards of Equal Height in Columns

Problem:

When dealing with Bootstrap cards, the heights of the cards can vary depending on the length of the card titles. This inconsistency can result in cards with different heights when arranged in columns.

Solution:

Utilize Flexbox, which is already employed in Bootstrap 4 columns, to ensure that all cards have the same height. By adding the class h-100 to each card, indicating a height of 100%, the cards will automatically fill the available height within their respective columns.

Example:

<code class="html"><div class="row">
  <div class="col-md-4 col-sm-6 col-12">
    <div class="card h-100">
      ...
    </div>
  </div>
  <!-- Similar cards and columns -->
</div></code>
Copy after login

Additional Notes:

  • Floating the cards is unnecessary, as they are already arranged in rows and columns.
  • Avoid nesting .col-* classes within .card-deck; instead, they should be placed directly within .row.

The above is the detailed content of How to Make Bootstrap 4 Cards Equal Height in Columns?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template