An alternative solution
You can align the link at the bottom of the card-body
by following these three steps:
- Apply the
d-flex
and flex-column
classes to card-body
- Wrap all the content of
card-body
in a div
.
- Use
flex: 1 1 auto
on this new div
Doing so, the newly created div
always takes all the available space. Hence, the link is always at the bottom of the card-body
.
.flex-grow {
flex: 1 1 auto;
}
<div class="card-body d-flex flex-column">
<div class="flex-grow">
<h4 class="card-title">Project One</h4>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet numquam aspernatur eum quasi sapiente nesciunt? Voluptatibus sit, repellat sequi itaque deserunt, dolores in, nesciunt, illum tempora ex quae? Nihil, dolorem!</p>
</div>
<a href="#" class="card-link text-info mt-auto">View CodePen</a>
</div>
Check this pen on CodePen
FYI, You can make an element occupy all the available space using this method.