【发布时间】:2019-03-17 18:03:04
【问题描述】:
我正在尝试使用表格创建表单。我一共有7个字段。我希望完成的是一行有 3 个字段,第二行有 3 个字段,最后一行将是扩展的最后一个字段。我尝试使用 colspan 但是 NextAction 的 editorfor 框并没有一直延伸。此字段的右侧有一个边距。我尝试创建一个 CSS 类来消除边距,但效果不佳。
如何才能让 NextAction 字段一直延伸到最后一列?
下面我为表格的最后 2 行添加了代码。
<table>
<tr>
<td>
@Html.LabelFor(model => model.Customer, htmlAttributes: new { @class = "control-label labelpadding" })
</td>
<td style="width:300px">
@Html.EditorFor(model => model.Customer, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer, "", new { @class = "text-danger" })
</td>
<td>
@Html.LabelFor(model => model.Principal, htmlAttributes: new { @class = "control-label col-md-2" })
</td>
<td style="width:300px">
@Html.EditorFor(model => model.Principal, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Principal, "", new { @class = "text-danger" })
</td>
<td>
@Html.LabelFor(model => model.Product, htmlAttributes: new { @class = "control-label labelpadding" })
</td>
<td>
@Html.EditorFor(model => model.Product, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Product, "", new { @class = "text-danger" })
</td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.Status, htmlAttributes: new { @class = "control-label labelpadding" })
</td>
<td>
@Html.DropDownListFor(m => m.Status, new SelectList(ViewBag.Status, "Status", "Text"), new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Status, "", new { @class = "text-danger" })
</td>
<td>
@Html.LabelFor(model => model.Value, htmlAttributes: new { @class = "control-label labelpadding" })
</td>
<td>
@Html.EditorFor(model => model.Value, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Value, "", new { @class = "text-danger" })
</td>
<td>
@Html.LabelFor(model => model.FollowUpDate, htmlAttributes: new { @class = "control-label labelpadding" })
</td>
<td>
<div>
<div class="input-group date" data-provide="datepicker">
@Html.EditorFor(model => model.FollowUpDate, new { htmlAttributes = new { @class = "form-control" } })
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.NextAction, htmlAttributes: new { @class = "control-label labelpadding" })
</td>
<td colspan="5">
@Html.EditorFor(model => model.NextAction, new { htmlAttributes = new { @class = "form-control ", @style = "margin-right: 0 !important;"} })
@Html.ValidationMessageFor(model => model.NextAction, "", new { @class = "text-danger" })
</td>
</tr>
</table>
【问题讨论】:
-
能贴出完整的代码吗?
-
我编辑了我的代码。我的桌子有完整的代码。
-
看起来您正在使用引导程序。为什么使用 HTML 表格而不是 Bootstrap 的 CSS 类?你能确认你是否在使用 Bootstrap 吗?
-
最初我使用的是引导程序,但列都搞砸了,所以我改用 HTML,因为我更了解它。
-
您必须将所有其他单元格跨到并扩大您的表格。现在表格宽度是 3,而你想要 5 这是不可能的
标签: c# html css asp.net asp.net-mvc