我有一个非常简单的 Bootstrap 3 表单,当我不使用 input-group-addon
时,我可以轻松(自动)对齐它。
在我的表单中使用它们后,无法对齐(由于添加了插件,带有插件的行更宽)
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="product_name" class="col-sm-2 control-label">Product name</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="product_name" placeholder="Product name">
</div>
</div>
<div class="form-group">
<label for="product_price" class="col-sm-2 control-label">Price</label>
<div class="col-sm-4 input-group">
<span class="input-group-addon">$</span>
<input type="text" class="form-control bfh-number" id="product_price" placeholder="Price" data-min="0" data-max="9999999">
<span class="input-group-addon">.00</span>
</div>
</div>
<div class="form-group">
<label for="product_description" class="col-sm-2 control-label">Description</label>
<div class="col-sm-6">
<textarea class="form-control" id="product_description" placeholder="Description" rows="5"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
JsFiddle:http://jsfiddle.net/Yzxy3/
最佳答案
输入组的 Bootstrap 文档说:
Don't mix input-group with other components. (see:http://getbootstrap.com/components/#input-groups)
Do not mix form groups or grid column classes directly with input groups. Instead, nest the input group inside of the form group or grid-related element."
所以你不能在同一个类中混合使用“col-sm-4”和“input-group”。您必须创建 2 个 div 类,第一个是“col-sm-4”,另一个是“input-group”
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="text" class="form-control bfh-number" id="product_price" placeholder="Price" data-min="0" data-max="9999999">
<span class="input-group-addon">.00</span>
</div>
</div>
关于html - 如何将 Bootstrap 形式的输入与输入组插件对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21340126/