我有这段代码:
<div class="mdl_bdy_frm">
@using (Html.BeginForm())
{
@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")
@Html.LabelFor(m => m.Login.UserName, new { @class = "adm" })
@Html.TextBoxFor(m => m.Login.UserName, new { @class = "adm", size = 30 })
@Html.ValidationMessageFor(m => m.Login.UserName)
@Html.LabelFor(m => m.Login.Password, new { @class = "adm" })
@Html.PasswordFor(m => m.Login.Password, new { @class = "adm", size = 30 })
@Html.ValidationMessageFor(m => m.Login.Password)
<br />
@Html.CheckBoxFor(m => m.Login.RememberMe, new { @class = "adm" })
@Html.LabelFor(m => m.Login.RememberMe, new { @class = "adm" })
<p><input type="submit" value="Login" /></p>
}
</div>
有没有办法让我的HTML.BeginForm以顶级边距的方式提供?如果可能的话,我想使用内置样式,因为它只是在一个地方使用。
答案 0 :(得分:5)
您只需将padding
添加到父div
。
<div class="mdl_bdy_frm" style="padding-top:20px;">
答案 1 :(得分:3)
Html.BeginForm( ..., ..., ..., New With {.style = "margin-top:20px;"})
答案 2 :(得分:1)
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { style = "margin: 10px;" }))