如何显示用户在页面中心登录包括所有控件?

时间:2017-07-03 01:35:57

标签: css html5 asp.net-mvc-4 bootstrap-4 bootstrap-ui

问题

如何在页面中心显示用户登录?

详情

左侧显示用户登录数据

实际上我需要在页面中心显示用户登录数据。

这包括用户名和密码的标签以及复选框和标签记住

用户登录标题和按钮提交以及用户名和密码的文本框

意思是全部转移到中心。

@model BookingPrograms.UsersLogin

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Login</title>
</head>
<body>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")


    @using (Html.BeginForm()) 
    {
        @Html.AntiForgeryToken()

        <div class="form-horizontal">
            <h4>UsersLogin</h4>
            <hr />
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
                @Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" })
                </div>
            </div>



            <div class="form-group">
                @Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(model => model.Remeber, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <div class="checkbox">
                        @Html.EditorFor(model => model.Remeber)
                        @Html.ValidationMessageFor(model => model.Remeber, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>


            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Login" class="btn btn-default" />
                </div>
            </div>
        </div>
    }

    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

使用自定义样式,您可以通过将一些规则设置为表单的类来实现此目的。但是请添加并使用不同的类而不是bootstrap form-horizo​​ntal类。

.form-horizontal { margin: 0 25px; // margin-top 0 while the right and left to 25px text-align: center; // This centers the button, texts and the rest. }

试试这个,让我知道你得到了什么。