.NET MVC 4 Visual Studio 2015 模板使内容宽度 100%?

.NET MVC 4 Visual Studio 2015 Template Make Content Width 100%?

我正在尝试使 VS 2015 中 MVC 的开箱即用模板的内容部分成为屏幕宽度的 100%。但我不知道在哪里做。我尝试将 width:100% 添加到 Site.css 中的正文中,但它没有用。我还尝试将它添加到 Site.css 中的 .body-content class。另外,我在 Site.css 中添加了 .Content 并添加了 width:100%,但它不起作用。有什么想法吗?

虽然模板使用了 bootstrap,但我认为这不是 100% bootstrap 的问题。也许这是微软使用的默认模板?

正如 a comment in 100% width Twitter Bootstrap 3 template 中指出的那样,您可以使用 container-fluid class 将宽度设置为 100%。

_Layout.cshtml 的第 13 行和第 32 行将 container 更改为 container-fluid,它按预期工作。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                </ul>
                @Html.Partial("_LoginPartial")
            </div>
        </div>
    </div>
    <div class="container-fluid body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>