Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center cards in bootstrap 4?

I am using bootstrap 4 alpha 3.
I want to center the card horizontally in the middle across the page.

Preview / link: http://codepen.io/vaibhavsingh97/full/VjRAXW

I have tried all the different options listed on the bootstrap 4 example page for cards.

How can I achieve this?

like image 775
Vaibhav Singh Avatar asked Aug 19 '16 04:08

Vaibhav Singh


People also ask

How do I center a content card in Bootstrap?

What you need to know, d-flex -> makes the element a flexbox. align-items-center - vertically aligns the content. justify-content-center - horizontally aligns the content.

How do I center an image in a Bootstrap card?

<img src="image_source" class="mx-auto d-block" ...>


1 Answers

Add the css for .card

.card {         margin: 0 auto; /* Added */         float: none; /* Added */         margin-bottom: 10px; /* Added */ } 

here is the pen

UPDATE: You can use the class .mx-auto available in bootstrap 4 to center cards.

like image 81
Shahil M Avatar answered Oct 09 '22 06:10

Shahil M