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

标签 css html 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>

最佳答案

使用自定义样式,您可以像这样为表单类设置一些规则来实现此目的。但是请添加并使用不同的类,而不是 Bootstrap 形式水平类。

.form-horizo​​ntal { 边距:0 25px;//margin-top 0 while right and left to 25px 文本对齐:居中;//这使按钮、文本和其余部分居中。 }

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

关于css - 如何在页面中心显示用户登录包括所有控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44876672/

相关文章:

c# - 如何将数据传递给 _Layout.cshtml

javascript - 使用javascript设置 "advanced"css类值?

网站的 HTML 布局无法正确显示

CSS 转换不适用于内联元素

html - 使范围 HTML 输入类型样式在 Chrome 和 Internet Explorer 之间兼容

c# - 模型绑定(bind) : POST data (possibly from Ruby) in MVC4/C#

html - 缩略图滚动边距(填充)问题

css - 动画闪烁

javascript - jQuery 在单击时动态更改图标功能

jquery - Asp.net MVC 4 Jquery 验证器未命中 InvalidHandler