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?
The Flexbox utility classes are your friend.
You can use justify-content-center
on .row
in this case.
.row {
background-color: lavender;
}
.col-md-3 {
background-color: gray;
}
<div class="container">
<div class="row justify-content-center">
<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>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>
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