问题
I'm trying to align Bootstrap 4 cards and using d-flex
along with align-self-stretch
for the cards themselves. Which is great.
However, I can't figure out how to get the part with the red border to float to the bottom. Any ideas by using Bootstrap 4 utilities only?
<div class="col-sm-12 col-md-6 col-lg-4 d-flex align-self-stretch">
<div class="card shadow-sm mb-4">
<img src="https://placehold.it/500x300" class="card-img-top" alt="">
<div class="card-body">
<h5 class="card-title text-uppercase">Longer title here that wraps two lines</h5>
<p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<div class="align-self-end border border-danger">
<p class="text-uppercase mb-0">Donors: 123</p>
<p class="text-uppercase">Funded: $1,234</p>
<a href="#" class="btn btn-info btn-block">View Details</a>
</div>
</div>
</div>
</div>
回答1:
Thanks to inputforcolor for help with the solution below, which keeps the cards the same height AND pushes the part I was looking for to the bottom.
<div class="col-sm-12 col-md-6 col-lg-4 d-flex align-self-stretch">
<div class="card shadow-sm mb-4">
<img src="https://placehold.it/500x300" class="card-img-top" alt="">
<div class="card-body d-flex flex-column">
<h5 class="card-title text-uppercase">Longer title here that wraps two lines</h5>
<p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<div class="mt-auto border border-danger">
<p class="text-uppercase mb-0">Donors: 123</p>
<p class="text-uppercase">Funded: $1,234</p>
<a href="#" class="btn btn-info btn-block">View Details</a>
</div>
</div>
</div>
</div>
来源:https://stackoverflow.com/questions/58228030/bootstrap-4-cards-same-height-and-bottom-justified