Reputation: 5187
I want to vertically middle align the buttons in bootstrap columns.
Fiddler: https://jsfiddle.net/ebwwvy6m/23/
HTML
<div class="row">
<div class="col-sm-3 vcenter">
<button type="button" class="btn btn-success btn-sm" id="BtnExport">Export</button>
</div>
<div class="col-sm-9">
<div class="row">
<div class="col-sm-6">
Comment
<textarea rows="2" class="form-control" id="TextAreaComment"></textarea>
</div>
<div class="col-sm-6 vcenter">
<button type="button" class="btn btn-primary btn-sm" id="BtnEntry">Abandon</button>
</div>
</div>
</div>
</div>
CSS:
.vcenter {
display:inline-block !important;
vertical-align:middle !important;
}
Expectation:
What I tried?
I tried following the solutions provided here,
But, I am not getting the solution. Any suggestion will be much appreciated. Thanks.
Upvotes: 9
Views: 20014
Reputation: 3022
.align-self-center
will work.
<div class="col-sm-6 align-self-center">
</div>
Upvotes: 36
Reputation: 326
You could use flexbox, just use the snippet on parent of the button in which you want to center the item.
(in your case .row div)
.row {
display: flex;
align-items: center;
}
Here is an example: https://jsfiddle.net/xsmnnLoc/
But this method doesn't work on IE 10 and lower
Upvotes: 18