I am currently working with bootstrap cards on two different web pages. The challenge I am facing is that on one page, the header text has a fixed height so I can easily match their card-header height using min-height. However, on the second page, the cards are dynamically generated, and I do not know the length or words of the text in advance. I want to ensure that all card-headers within a row have the same height.
Is there a way to calculate the min-height based on the tallest card-header in a row?
Although I am already using card-deck, which sets the height for the whole card, my specific issue revolves around the card-header element. I need all card-headers to be uniform in height regardless of the content inside.
https://i.sstatic.net/95cH6.png
Example:
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <div class="card-deck my-3 text-center"> <div class="card mb-4 box-shadow"> <div class="card-header align-items-center d-flex justify-content-center card-header-height"> <h4 class="my-0 font-weight-normal">Lorem Ipsum Lorem Ipsum Lorem Ipsum Ipsum</h4> </div> <div class="card-image"> <img class="img-fluid" src="img_avatar1.png"> </div> <div class="card-body"> <ul class="list-unstyled mt-3 mb-4"> </ul> </div> </div> <div class="card mb-4 box-shadow"> <div class="card-header align-items-center d-flex justify-content-center card-header-height"> <h4 class="my-0 font-weight-normal">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum </h4> </div> <div class="card-image"> <img class="img-fluid" src="img_avatar1.png"> </div> <div class="card-body"> <ul class="list-unstyled mt-3 mb-4"> </ul> </div> </div> <div class="card mb-4 box-shadow"> <div class="card-header align-items-center d-flex justify-content-center card-header-height"> <h4 class="my-0 font-weight-normal">Lorem Ipsum Lorem Ipsum </h4> </div> <div class="card-image"> <img class="img-fluid" src="img_avatar1.png"> </div> <div class="card-body"> <ul class="list-unstyled mt-3 mb-4"> </ul> </div> </div> </div> </div> </body> </html>Update I encountered a similar issue when adding a list (ul) and list-items (li) into the card-body. It took me some time to realize that the varying lengths of the li text were affecting the overall look of the card-headers. Ensure that your li text has a consistent length to maintain the uniformity of the card-headers.