Asp.net mvc MVC4-如何重新排列脚手架生成的字段
我有一个由MVC4 scaffolding创建的.cshtml文件,看起来像这样:Asp.net mvc MVC4-如何重新排列脚手架生成的字段,asp.net-mvc,html,scaffolding,asp.net-mvc-scaffolding,Asp.net Mvc,Html,Scaffolding,Asp.net Mvc Scaffolding,我有一个由MVC4 scaffolding创建的.cshtml文件,看起来像这样: @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>BicycleSellerListing</legend> <div class="editor-label"> @Html.LabelF
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>BicycleSellerListing</legend>
<div class="editor-label">
@Html.LabelFor(model => model.BicycleManfacturer)
</div>
<div class="editor-field">
@Html.DropDownList("ManufacturerList")
</div>
<div class="editor-label">
@Html.LabelFor(model => model.BicycleType)
</div>
<div class="editor-field">
@Html.DropDownList("TypeList")
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ListingPrice)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ListingPrice)
@Html.ValidationMessageFor(model => model.ListingPrice)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Comments)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Comments)
@Html.ValidationMessageFor(model => model.Comments)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
@使用(Html.BeginForm()){
@Html.ValidationSummary(true)
自行车滑行
@LabelFor(model=>model.bicycleMacturer)
@Html.DropDownList(“制造商列表”)
@LabelFor(model=>model.BicycleType)
@Html.DropDownList(“类型列表”)
@LabelFor(model=>model.ListingPrice)
@EditorFor(model=>model.ListingPrice)
@Html.ValidationMessageFor(model=>model.ListingPrice)
@LabelFor(model=>model.Comments)
@EditorFor(model=>model.Comments)
@Html.ValidationMessageFor(model=>model.Comments)
我不想在单个垂直列中生成标签和列,而是想重新安排它,以便在一列中有标签,在第二列中有编辑器字段(更像是传统的数据输入表单)。我对MVC 4和HTML5非常陌生,不知道如何去做。如果有人能帮我重新安排.cshtml代码来完成这项工作,我将非常感激。这里有一种方法使用
float:left
和:before
使用:before如果您需要支持(<9),那么您可以添加一个元素来清除每个字段和标签之间的内容
HTML
.editor-label {
float:left;
width:20%;
}
.editor-label:before {
clear:left;
}
.editor-field {
float:left;
width:80%;
}
<div class="editor-label">
label1
</div>
<div class="editor-field">
@Html.DropDownList("ManufacturerList")
</div>
<div class="clear"></div>
.clear {
clear:left;
}