2

I'm trying to make the content portion of the out-of-the-box template for MVC in VS 2015 to be 100% the width of the screen. But I can't figure out where to do it. I tried adding width:100% to the body in Site.css, but it did not work. I also tried adding it to the .body-content class in Site.css. Also, I added .Content to Site.css and added width:100%, but it does not work. Any ideas?

Though the template uses bootstrap, I don't think it's a 100% bootstrap issue. Perhaps it's something with the default template that Microsoft uses?

Andy B.
  • 33
  • 2
  • 7
  • Possible duplicate of [100% width Twitter Bootstrap 3 template](http://stackoverflow.com/questions/18449918/100-width-twitter-bootstrap-3-template) – NightOwl888 Jun 04 '16 at 16:49
  • I tried creating a custom class and wrapped the content like that answer to the question said, but it didn't work. That seems to be bootstrap specific, but I think it may be default mvc template specific? – Andy B. Jun 04 '16 at 16:56

1 Answers1

3

As was pointed out in a comment in 100% width Twitter Bootstrap 3 template, you can use the container-fluid class to make the width 100%.

Change container to container-fluid on lines 13 and 32 of _Layout.cshtml and it works as expected.

<!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>
Community
  • 1
  • 1
NightOwl888
  • 55,572
  • 24
  • 139
  • 212