How can I apply a top margin to my Html.BeginForm

為{幸葍}努か 提交于 2019-12-24 03:25:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!