I am trying to use boostrap4 in order to create a card header where the title is text-align center of the card-header, an icone that is right align and both vertically center middle
I tried some things but nothing seems to get to what I want;
++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ +
+ title icone+
+ +
++++++++++++++++++++++++++++++++++++++++++++++++++++++
code:
<div class="card-header text-center bg-dark text-white">
<div class="row h-100">
<div class="col-md-11">
<h5>Complete models list</h5>
</div>
<div class=col-md-1>
<i class="far fa-question-circle float-right align-self-center"></i>
</div>
</div>
</div>
any idea how to make it work ?
Use align-items-center
on the row
...
<div class="card-header text-center bg-dark text-white">
<div class="row align-items-center">
<div class="col-md-11">
<h5>Complete models list</h5>
</div>
<div class="col-md-1">
<i class="fa fa-question-circle float-right"></i>
</div>
</div>
</div>
Or, to dead center the <h5>
while keeping the icon right aligned, use a d-flex align-items-center
div with auto-margins (ml-auto
) to push the icon to the right...
<div class="card">
<div class="card-header text-center bg-dark text-white">
<div class="d-flex align-items-center">
<h5 class="mx-auto w-100">Complete models list</h5>
<i class="fa fa-question-circle ml-auto"></i>
</div>
</div>
<div class="card-body">
<p class="text-center">center</p>
</div>
</div>
Demo of both options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With