gpt4 book ai didi

html - 引导安装 MVC 4 后无法整理登录页面

转载 作者:行者123 更新时间:2023-11-28 07:09:52 26 4
gpt4 key购买 nike

我在 mvc 4 上有一个标准的登录页面,它运行良好,但我的 html 知识非常薄弱,我需要一个快速的答案来在我安装 twitter bootstrap 后整理表单,用户名和密码标签贴在同一个上表单中的一行,有人可以推荐一个快速修复来整理我的代码吗,谢谢

@model MvcApplication2.Models.login_details

@{
ViewBag.Title = "Log in";
}
<br /><br /><br />
<h2>@ViewBag.Title.</h2>
<div class="row">
<div class="col-md-8">
<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, "", new { @class = "text-danger" })
<div class="col-md-10">
@Html.LabelFor(m => m.username, new { @class = "col-md-2 control-label"})
<div class="col-md-10">
@Html.TextBoxFor(m => m.username, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.username, "", new { @class = "text-danger"})
</div>
</div>

<div class="form-group">
@Html.LabelFor(m => m.password, new { @class = "col-md-2 control-label"})
<div class="col-md-10">

@Html.PasswordFor(m => m.password, new { @class = "form-control"})
@Html.ValidationMessageFor(m => m.password, "", new { @class = "text-danger"})
</div>
</div>

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

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

最佳答案

简单 :)只需将 LabelFor 的类从 col-md-2 更改为 col-md-3,然后添加另一个元素,text-left。

所以你的标签应该是这样的:

@Html.LabelFor(m => m.Email, new { @class = "col-md-3 control-label text-left" })
@Html.LabelFor(m => m.Password, new { @class = "col-md-3 control-label text-left" })

然后转到 Site.css (~/Content/site.css) 并将以下内容添加到底部:

.form-horizontal .control-label.text-left{
text-align: left;
}

done!

我建议您学习 HTML/JS/Bootstrap,就好像您专业地制作网站一样,您几乎总是必须能够胜任基本的 HTML/JS/Bootstrap(有时)

关于html - 引导安装 MVC 4 后无法整理登录页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32727143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com