I'm trying to vertically align checkboxes for a column of checkboxes + labels. Ideally, I'd like the elements to be in the center of the page but with the checkboxes themselves vertically aligned.
<div class="row">
<div class="span12 pagination-centered">
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">sdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asfdasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
</div>
</div>
Simply add these styles
input[type="checkbox"] {
vertical-align: middle;
}
.span12.pagination-centered {
margin: 25px auto;
width: 100px;
}
input[type="checkbox"] {
vertical-align: middle;
}
.span12.pagination-centered {
margin: 50px auto;
width: 100px;
}
<div class="row">
<div class="span12 pagination-centered">
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">sdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asfdasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
</div>
</div>
This is one way to do it
<div class="row">
<div class="col-md-4 "></div>
<div class="col-md-4" style="text-align:center">
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">sdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asfdasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
</div>
<div class="col-md-4 "></div>
</div>
Another way to do this is:
<div class="row">
<div class="col-md-12" style="text-align:center">
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">sdfasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asfdasdf</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">asdfasdf</label>
</div>
</div>
</div>
Both produce the same result
You can try like this,
<div class="container">
<div class="row vertical-align">
<div class="col-xs-6"> ... </div>
<div class="col-xs-6"> ... </div>
</div>
</div>
css
.vertical-align {
align-items: center;
}
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