Asp.Net MVC 5 +引导。 如何使输入适应屏幕宽度?(Asp.Net MVC 5 +

2019-10-23 10:49发布

我真的不知道我在做什么错。 我想我下面我的按钮的大小相同文本框。 我已经尝试过在CSHTML但都没有成功改变了很多。

下面我CSHTML文件:

@model SomeModel.Models.LoginViewModel

<div class="row">
    <div class="col-md-8 col-sm-12 col-xs-12">
        <section id="loginForm">
            @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
            {
                @Html.AntiForgeryToken()
                <hr />
                @Html.ValidationSummary(true)
                <div class="form-group">
                    @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
                    <div class="col-md-12">
                        @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.UserName)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
                    <div class="col-md-12">
                        @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Password)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12 col-xs-12">
                        <button type="submit" class="btn btn-success btn-block">Entrar</button>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-10 col-sm-12 col-xs-12 visible-sm visible-xs">
                        <button type="submit" class="btn btn-primary btn-block">Ainda Não Tenho Conta</button>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-10 col-sm-12 col-xs-12 visible-sm visible-xs">
                        <button type="submit" class="btn btn-info btn-block">Esqueci Meu Usuário Ou Senha</button>
                    </div>
                </div>
                <p>
                    @Html.ActionLink("Register", "Register") if you don't have a local account.
                </p>
            }
        </section>
    </div>
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

我究竟做错了什么?

Answer 1:

默认MVC5模板具有的site.css CSS规则:

input, select, textarea { max-width: 280px; }

我通常会删除该规则。

它会导致与引导V3输入组的问题在输入框没有延伸到其容器的宽度。



文章来源: Asp.Net MVC 5 + Bootstrap. How make inputs fit screen width?