我正在尝试在水平表单组类中显示三个小文本框元素。使用代码
<div class="form-group">
<label class="col-lg-3 control-label input-sm">Date of Birth:</label>
<div class="col-lg-4">
<div class="row">
<div class="col-lg-4">
<input type="text" id="txt_month" name="txt_month" class="form-control input-sm" placeholder="MM" required maxlength="2" data-validation-required-message="Month is required" >
</div>
<div class="col-lg-4">
<input type="text" id="txt_day" name="txt_day" class="form-control input-sm" placeholder="DD" required maxlength="2" data-validation-required-message="Day is required" >
</div>
<div class="col-lg-4">
<input type="text" id="txt_year" name="txt_year" class="form-control input-sm" placeholder="YY" required maxlength="4" data-validation-required-message="Year is required" >
</div>
</div>
<p class="help-block"></p>
</div>
</div>
结果:
是否有更好的方法来显示彼此靠近的多个文本框。表格中的其他元素水平显示。
更新#
使用带有许多其他修改的内联表单类后,我得到了正确的结果。这是更新的代码。
<div class="form-group">
<label class="col-lg-3 control-label input-sm">Date of Birth:</label>
<div class="col-lg-7">
<div class="form-inline">
<div class="form-group ">
<div class="col-lg-3">
<label class="sronly" for="txt_month">Enter Month</label>
<input type="text" id="txt_month" name="txt_month" class="form-control input-sm" style="width:60px" placeholder="MM" required maxlength="2" data-validation-required-message="Month is required" >
</div>
</div>
<div class="form-group">
<div class="col-lg-3">
<label class="sronly" for="txt_day">Enter Day</label>
<input type="text" id="txt_day" name="txt_day" class="form-control input-sm" style="width:60px" placeholder="DD" required maxlength="2" data-validation-required-message="Day is required" >
</div>
</div>
<div class="form-group">
<div class="col-lg-3">
<label class="sronly" for="txt_year">Enter Year</label>
<input type="text" id="txt_year" name="txt_year" class="form-control input-sm" style="width:60px" placeholder="YY" required maxlength="4" data-validation-required-message="Year is required" >
</div>
</div>
</div>
<p class="help-block"></p>
</div>
</div>
正确结果:
答案 0 :(得分:12)
这个答案真的帮助我用BS3制作了我的表格。
但我希望它看起来像这样:
所以,我对上面的内容进行了修改,并将'sr-only'类添加到我想隐藏的标签中(因此屏幕阅读器仍然会选择它们),并更改了col大小。
(注意:OP使用'sronly'类而不是'sr-only'类对我不起作用)
<div class="form-group">
<label class="col-lg-3 control-label ">City & County:</label>
<div class="col-lg-9">
<div class="form-inline">
<div class="form-group ">
<div class="col-lg-12">
<label class="sr-only" for="city">City</label>
<input type="text" id="city" name="city" class="form-control " placeholder="E.g. Manchester" >
</div>
</div>
<div class="form-group ">
<div class="col-lg-12">
<label class="sr-only" for="county">County</label>
<input type="text" id="county" name="county" class="form-control " placeholder="E.g. Lancashire" >
</div>
</div>
</div>
</div>
</div>
答案 1 :(得分:3)
是使用Inline Forms。查看他们的文档