【发布时间】:2013-08-13 21:45:38
【问题描述】:
将input-group 附加到form-inline 时,input-group 将出现在表单下方的“新行”上,而不是与其他控件内联。
这似乎是因为input-group 包装类将display 设置为table,而其他工作正常的输入将display 设置为inline-block。当然,不可能给input-group提供inline-block显示,因为它的子add-on跨度有display: table-cell,需要父的属性才能正确对齐。
所以我的问题是:是否可以在内联表单中使用input-group仅使用 Bootstrap 类?如果没有,最好的解决方法是允许使用自定义类。
这是一个demo 说明我的观点。代码如下:
<form action="" class="form-inline">
<input type="text" class="form-control" placeholder="Works with" style="width: 100px;"/>
<input type="text" class="form-control" placeholder="Text Inputs" style="width: 120px;"/>
<div class="checkbox">
<label>
<input type="checkbox" /> and Checkboxes
</label>
</div>
<select class="form-control" style="width: 150px;">
<option>and Selects</option>
</select>
<button type="submit" class="btn btn-default">and Buttons</button>
<div class="input-group" style="width: 220px;">
<span class="input-group-addon">BUT</span>
<input type="text" class="form-control" placeholder="not with input-groups" />
</div>
</form>
【问题讨论】:
-
这是一个错误,也许你可以在
input-group类中使用pull-right。 -
是的,这可能是一个错误。无论我的情况如何,使用
pull-right都不是一个好的解决方案:输入之间的垂直间距丢失,并且如果有两个输入组,它们将被错误地显示。恕我直言,最好使用带有自定义类的功能解决方案,而不是使用内置类的错误破解。
标签: html css twitter-bootstrap twitter-bootstrap-3