我创建了一个MVC表单。 一切正常,但是,当显示错误消息时,它们会向左移动。
这是一段代码:
<div style="text-align: center; padding-top: 40px;">
<h2 style="color: white;">Title</h2>
@using (Html.BeginForm())
{
<div>
@Html.EditorForModel()
<p><input type="submit" class="k-primary" value="Log In" /></p>
</div>
}
</div>
这是我的编辑模板:
<div style="margin: 0px auto; text-align: center; display: table;">
<table>
<tr>
<td>@Html.EditorFor(x => x.UserName, new { htmlAttributes = new { @class = "form-control", placeholder = "username" } })</td>
<td>@Html.ValidationMessageFor(x => x.UserName,"", new { @class = "text-danger"})</td>
</tr>
<tr>
<td>@Html.EditorFor(x => x.Password, new { htmlAttributes = new { @class = "form-control", placeholder = "password" } })</td>
<td>@Html.ValidationMessageFor(x => x.Password)</td>
</tr>
<tr style="height:70px;">
<td colspan="2"><input type="submit" class="k-primary" value="Log In" /></td>
</tr>
</table>
</div>
这是生成的代码:
我缺少什么,所以表格不会移动到任何地方并保持固定?