[英]Bootstrap Form Horizontal Alignment Errors
我的文本框根本无法与表单正确对齐。 我在ASP.NET MVC 4中使用Bootstrap。如您所见,我使用的是水平窗体div,但是不确定我的元素为什么全部出现在外。 如何获得与标签对齐的元素?
<div class="form-horizontal">
@Html.ValidationSummary(true)
<div class="form-group">
@Html.Label("Please enter the Inventory No", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Log.InventoryNo, new {maxlength = "10", autocomplete = "off"})
@Html.ValidationMessageFor(model => model.Log.InventoryNo)
<span class="help-block">Inventory No is physically located on the Inventory sticker device on the side of a device.</span>
</div>
</div>
<div class="form-group">
@Html.Label("Please add any keywords", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Tags, new {autocomplete = "off", maxlength = "250"})
@Html.ValidationMessageFor(model => model.Tags)
<span class="help-block">Required: Enter the keywords of your fault description. For emample, Printer, Jammed, Paper and etc. </span>
</div>
</div>
<div class="form-group">
@Html.Label("Please enter a description of the fault", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.IncidentDescription, new {maxlength = "90"})
@Html.ValidationMessageFor(model => model.IncidentDescription)
</div>
</div>
首先,我将form-control
类添加到您的文本框和文本区域,即
@Html.TextBoxFor(model => model.Log.InventoryNo, new {maxlength = "10", autocomplete = "off", @class="form-control"})
....
@Html.TextAreaFor(model => model.Tags, new {autocomplete = "off", maxlength = "250", @class="form-control"})
有关表单控制的更多信息,请参见此处:
其次,您需要像这样在列div中添加标签:
<div class="form-group">
<div class="col-md-10">
@Html.Label("Please enter a description of the fault", new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.IncidentDescription, new {maxlength = "90"})
@Html.ValidationMessageFor(model => model.IncidentDescription)
</div>
</div>
这是一个简单的例子:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.