问题
I have this code:
<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>
Is there a way that I can give my HTML.BeginForm at top-margin style? If possible I would like to do this with an inline style as its just used in the one place.
回答1:
Html.BeginForm( ..., ..., ..., New With {.style = "margin-top:20px;"})
See: How to add id HTML attribute in ASP.NET MVC w/ VB.NET
回答2:
You could just add padding
to the parent div
.
<div class="mdl_bdy_frm" style="padding-top:20px;">
回答3:
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { style = "margin: 10px;" }))
来源:https://stackoverflow.com/questions/6815762/how-can-i-apply-a-top-margin-to-my-html-beginform