我已尝试将.pull-right
添加到按钮,但这两个元素不再垂直对齐,并且.form-group
个input
元素的边距会变小。
HTML
<form class="form">
<div class="form-group">
<label>Type</label>
<button class="btn btn-default">
<span class="glyphicon glyphicon-plus-sign"></span>
</button>
</div>
<div class="form-group">
<select class="form-control half-width-form-control">
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
<input class="form-control half-width-form-control" type="number"></input>
</div>
</form>
答案 0 :(得分:0)
您可以将表单横向版本与.form-horizontal
一起使用,并添加.control-label
以使您的标签垂直对齐:
<div class="container">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label">Type</label>
<button class="btn btn-default pull-right">
<span class="glyphicon glyphicon-plus-sign"></span>
</button>
</div>
<div class="form-group">
<select class="form-control half-width-form-control">
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
<input class="form-control half-width-form-control" type="number"></input>
</div>
</form>
</div>
<强> Updated Fiddle 强>