我将Bootstrap表单类从form-horizontal
更改为form-inline
,并且所有格式都受到干扰。如何获得正确的内联格式?
这是第一个表格字段的示例代码
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<label class="control-label col-md-2" for="Med_Name">Medicine Name</label>
<div class="col-md-10">
@Html.EditorFor(model => model.Med_Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Med_Name, "", new { @class = "text-danger" })
</div>
</div>
@* Rest Of The HTML Code Is Not Shown *@
答案 0 :(得分:3)
当您将样式设置为inline
时,您还需要将其包装在各自的UI模式中,然后在textboxes
中包装前3 col-md-4
,然后将所有这3个textboxes
包裹起来在col-md-12
中作为他们的父级..或者您甚至可以尝试将其包含在row
元素中,每个3 textboxes
或根据您的要求。
<强>实施例强>
<div class="col-md-12"> <!--Even row instead of col-md-12-->
<div class="form-group col-md-4"> <!--col-md-4 for other elements too-->
<label class="control-label col-md-2" for="Med_Name">Trade Price</label>
<div class="col-md-10">
@Html.EditorFor(model => model.Med_Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Med_Name, "", new { @class = "text-danger" })
</div>
</div>
<!--Same goes for other 2 elements-->
</div>
<div class="col-md-12"> <!--Even row instead of col-md-12-->
<div class="form-group col-md-4">
<label class="control-label col-md-2" for="Med_Name">Medicine Name</label>
<div class="col-md-10">
@Html.EditorFor(model => model.Med_Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Med_Name, "", new { @class = "text-danger" })
</div>
</div>
<!--Same goes for other 2 elements-->
</div>