Is there a way to have three col-md-3 columns and center them. Offset doesn’t work, because I’d have to offset the first column for a column and a half. So is there another way to do this?
Here’s the outline of the code:
.col-md-3 {
background-color: #e2e2e2;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-3">First column</div>
<div class="col-md-3">Second column</div>
<div class="col-md-3">Third column</div>
</div>
</div>
The answers I managed to find on SO were all related to Bootstrap 3 and lower. And didn’t work with Bootstrap 4. Can someone take a look and let me know?
3
Answers
Yes
Apply
justify-content:center
to the row.As indicated BS4 has their own class for this
.justify-content-center
The Flexbox utility classes are your friend.
You can use
justify-content-center
on.row
in this case.how about
flex
: