Using bootstrap 3, how to align vertically and put a button at the bottom when it doesn't have a label above his column?
Like this situation:
<div class="container">
<div class="row">
<div class="col-xs-3">
<label class="control-label">Field 1</label>
<input type="text" class="form-control">
</div>
<div class="col-xs-3 ">
<div class="text-center">
<button class="btn btn-primary">Swap!</button>
</div>
</div>
<div class="col-xs-3">
<label class="control-label">Field 2</label>
<input type="text" class="form-control">
</div>
</div>
</div>
I have used mainly three solutions:
Does anyone have a better way to fix this? Or am I doing the layout structure wrong?
Thanks!
You can try aligning with vertical-align:
.col-xs-3 {display:inline-block; vertical-align:bottom; float:none;}
Just make sure there are no spaces in the html between the each of the col-xs-3 divs. Or use a comment to divide them, like this:
<div>...</div><!-- space --><div>...</div>
https://jsfiddle.net/yw0a6689/
UPDATE: Instead of doing this for every column, you can do it generally like this:
.container > .row > div {display:inline-block; vertical-align:bottom; float:none;}
Or more specific by giving the row a class like .myrow and then declaring:
.myrow > div {display:inline-block; vertical-align:bottom; float:none;}