11

Hi I am trying to fix my Jumbotron to be full width of the screen but somehow it need a 15px padding-left, padding-right. If I remove the padding the horizontal scrollbar appears with a 30px right margin. I am using the default Bootstrap ver 3.0.3 and default VS2013 layout. As per this link I removed the Jumbotron outside all .container my page looks sth like this

<body>
<div class="navbar navbar-inverse navbar-fixed-top">.... Navigation stuff</div>
<div class="jumbotron specialjum">
<div class="over container body-content">
....page headers and other stuff
</div>
</div>
<p class="just container body-content">
... body text
</p>
</body>

/////////////////////////////////////////////////

body {
padding-top: 50px;
padding-bottom: 20px;
/*background:url("../Images/ps_neutral.png") repeat;*/
}
                    
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
.just {
text-align: justify;
}
.specialjum {
background: url('http://fc00.deviantart.net/fs70/i/2013/339/7/1/princess_kenny_korosu_by_theshadowstone-d6wu2zo.png') center;
color:#fff;
background-size: cover; 
}

Edit: Firefox + Chrome + IE10 results ===|================|===

Any Ideas on how to fix the layout? I haven't touch the Bootstrap CSS which I updated using Nuget.

Community
  • 1
  • 1
Flood Gravemind
  • 3,773
  • 12
  • 47
  • 79

7 Answers7

6

Just to share my experience after creating an MVC web application in Visual Studio 2013 I could not get the jumbotron to stretch the width of the screen no matter what I did. I ultimately found that it was being blocked by a default **container body-content tag on the Views/Shared/_Layout.cshtml page. After removing the tag it displayed correctly. Hope that helps anyone with a similar situation to mine.

Code

Before

After

snapper
  • 210
  • 3
  • 14
5

The solution was simple. This is how I div it:

    <body>
    <div class="navbar navbar-inverse navbar-fixed-top">.... Navigation stuff</div>
    <div> <===================this Div wrapping jumbotron
    <div class="jumbotron specialjum">
    <div class="over container body-content">
    ....page headers and other stuff
    </div>
    </div>
    <p class="just container body-content">
    ... body text
    </p>
    </div>
    </body>

No changes to any part of the CSS. I don't know why it works, but it just works.

peterh
  • 11,875
  • 18
  • 85
  • 108
Flood Gravemind
  • 3,773
  • 12
  • 47
  • 79
  • 11
    It works because the createors of bootstrap are smart! From the bootstrap docs "To make the jumbotron full width, and without rounded corners, place it outside all .containers and instead add a .container within." http://getbootstrap.com/components/#jumbotron – nomis Feb 06 '15 at 20:21
2

If you're just trying to remove the padding, then you'll want to put padding:0; in your .specialjum and make sure that the custom stylesheet is called after bootstrap. Otherwise add padding:0!important; if it needs to be called before. Also repeat this for margin-right: and add in width:100%; if it isn't stretching to the width of the page which I believe it should already.

See this jsFiddle

Jeremy
  • 310
  • 1
  • 5
  • 18
1

For anyone else that may end up here I have an alternative solution. I ran into this problem, but I just couldn't take my Jumbotron outside of it's container. What I did is just wrapped it in a <div class="row"></div>. I'm still learning bootstrap so I don't know if this will cause any problems down the road, but for now it works pretty good.

Peavey2787
  • 128
  • 1
  • 10
1

In order to make the jumbotron full width, and without rounded corners, place it outside all .containers and instead add a .container within.

1

Another option in _Layout.cshtml (Where "Home" is the page you want to be full width):

@if (ViewData["Title"].Equals("Home"))
{
    @RenderBody()
}
else
{
    <div class="container container-main">
        <main role="main">
            @RenderBody()
        </main>
    </div>
}
Rob L
  • 2,124
  • 3
  • 22
  • 50
0

Change width of .container to 100%:

container { width: 100% }
sushain97
  • 2,752
  • 1
  • 25
  • 36
Mohammed Raja
  • 207
  • 2
  • 9