gpt4 book ai didi

asp.net - Bootstrap 表单水平对齐错误

转载 作者:行者123 更新时间:2023-11-28 12:15:45 26 4
gpt4 key购买 nike

enter image description here

我的文本框根本没有与我的表单正确对齐。我在 ASP.NET MVC 4 中使用 Bootstrap。如您所见,我使用的是 form-horizo​​ntal 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"})

有关表单控件的更多信息,请参见此处:

http://getbootstrap.com/css/

其次,您需要像这样在列 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>

这里有一个简单的例子:

http://www.bootply.com/128038

关于asp.net - Bootstrap 表单水平对齐错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22911713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com