我有一个Razor
视图,我希望将一个文本字段(通过@Html.EditFor
实现)与下拉列表(通过@Html.DropDownListFor
实现)并排放置。但是,当在同一个div中使用这些时,下拉列表将被放在下一行。我怎么能克服这个?
<div class="form-group">
@Html.LabelFor(model => model.Size.SizeNutFacts.BaseUnitAmount, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Size.SizeNutFacts.BaseUnitAmount, new { htmlAttributes = new { @class = "form-control" } })
@Html.DropDownListFor(m => m.SelectedBaseUnit, Model.BaseUnitOptions, "Select Unit", new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Size.SizeNutFacts.BaseUnitAmount, "", new { @class = "text-danger" })
</div>
</div>
答案 0 :(得分:0)
您需要在编辑器和下拉列表中添加一个包含inline-block
的包装类div,以防止它们填满整行,从而将它们放在彼此旁边,如下所示:
.wrapper {
display: inline-block;
}