I am using a bootstrap to create cards for my site. I am trying to center the card contents of the grid image cards. I have tried applying class="center" into various parts and the items are still all aligned left. This is a snippet of one of the grids
<div class="col">
<div class="card">
<i class="fa fa-medkit fa-5x" aria-hidden="true" class="center"></i>
<div class="card-body">
<h5 class="card-title" >Allied Health</h5>
<p class="card-text" class="center"></p>
</div>
</div>
</div>
I added class="center" and even class="all contents aligned center" into different parts, but there was no change.
2
Answers
add the attribute display: flexbox; to your div element.
You should add a justify-content-center class in it, to make it center the content in a flexbox way.
I can give you a useful link :center element in bootstrap
Add
text-center
to thecard
element.Also, note that you can only have one class attribute per html element. To add multiple classes to a single element, you separate them with a space.