Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change in 3.0.1: Nested containers don't properly size #11436

Closed
rwgodfrey opened this issue Nov 10, 2013 · 16 comments
Closed

Breaking change in 3.0.1: Nested containers don't properly size #11436

rwgodfrey opened this issue Nov 10, 2013 · 16 comments
Labels

Comments

@rwgodfrey
Copy link

The media queries in v3.0.0 set a "max-width" for the ".container" class. This was changed in 3.0.1 to set a "width" instead to support IE 8 which doesn't support "max-width".

This breaks nested ".container" DIVs because the interior ".container" DIVs calculate based on a fixed width instead of the width available in the parent. The net effect is that content overflows on the right.

Example:

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <link href="Bootstrap/css/bootstrap.css" rel="stylesheet" />
    </head>
    <body>
        <div class="container" style="border: 1px solid black; background-color:  #808080;">
            <div class="container" style="border: 1px solid black; background-color:  #fcf5eb;">
                <div class="container">
                    <div class="row" style="height: 200px;"></div>
                    <div class="row">
                        <div class="col-md-4" style="min-height: 200px; background-color: red;"></div>
                        <div class="col-md-4" style="min-height: 200px; background-color: yellow;"></div>
                        <div class="col-md-4" style="min-height: 200px; background-color: blue;">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
@zlatanvasovic
Copy link
Contributor

I'm unable to reproduce that.

Test case: http://jsfiddle.net/2cd4j/embedded/result/

@rwgodfrey
Copy link
Author

It happens in your jsfiddle example too but you can't see it because you don't have any visible reference for the outside container. Here is the same example but with a border added to the outside container.

http://jsfiddle.net/kMnWc/embedded/result/

Note that on my machine, the browser window size must be 787 or higher to see the overflow.

@zlatanvasovic
Copy link
Contributor

Your border depends on padding. I don't see a usage point with .container inside .container with borders.

@rwgodfrey
Copy link
Author

I think it would be common with sites that use nested master pages (such as ASP.NET MVC sites). I have a couple of ASP.NET MVC sites where the main layout page has a container with a border that surrounds the entire content area of the page. Pages that use that layout page then have containers in them for positioning of content.

Here's an example: http://www.cfgrace.com

Now that site is still using v3.0.0, but when I change it to v3.0.2 the twitter panel on the right-hand side overflows past the content border at wider page widths. A couple of other sites with similar layouts do the same thing.

@rwgodfrey
Copy link
Author

Also, it's not the border. Changing the outside container to remove the border and just use a background color demonstrates the same behavior.

http://jsfiddle.net/dQY3t/embedded/result/

@zlatanvasovic
Copy link
Contributor

If I wasn't clear, I think that your box model depends on padding. You are right about container's fixed width, I'm working on a fix. ;)

@ghost
Copy link

ghost commented Nov 10, 2013

hogy lenne közös helyszíneken, hogy a beágyazott mester oldalak (mint például ASP.NET MVC helyek). hogy a gépemen, a böngésző ablak mérete legyen 787 vagy nagyobb, hogy a túlfolyó.

@ghost
Copy link

ghost commented Nov 10, 2013

@MarcioBarrientos
Copy link

I have this problem too, I change the "width" to "max-width" in the .container and now works fine.

example:
< div class="row">
< div class="col-md-8">
< div class="container">
This content will extends to width size and overflows to the right column.
< /div>
< /div>
< div class="col-md-4">
Content at right side
< /div>
< /div>

@rwgodfrey
Copy link
Author

I initially changed width back to max-width, but I ended up just refactoring my site to take out the nested containers. I created my own class called "nested-container" to apply the centering and padding that I was getting from the "container" class.

@mdo
Copy link
Member

mdo commented Nov 30, 2013

It's definitely the fixed width and the padding. Nested containers worked before because of max-width but when we changed that in a prior release, it stopped working. However, it still didn't work completely because each nested container would become narrower and narrower.

@mdo
Copy link
Member

mdo commented Nov 30, 2013

See this example for a solution: http://jsbin.com/IhEZadu/1.

Definitely need more testing and feedback though to see if this works everywhere—outdenting nested containers might not always make sense. I think for the time being we just don't recommend it.

Thoughts from anyone else?

@zlatanvasovic
Copy link
Contributor

My recommendation is to avoid nested containers.

Fluid containers and rows would fix this (.row -> .container => nesting). :)

2013/12/1 Mark Otto [email protected]

See this example for a solution: http://jsbin.com/IhEZadu/1.

Definitely need more testing and feedback though to see if this works
everywhere—outdenting nested containers might not always make sense. I
think for the time being we just don't recommend it.

Thoughts from anyone else?


Reply to this email directly or view it on GitHubhttps://github.com//issues/11436#issuecomment-29563389
.

Zlatan Vasović - ZDroid

@carasmo
Copy link

carasmo commented Dec 1, 2013

At some point, maybe instead of .container it should be called .page-max-width-container or something so people won't nest it. I assumed that .container is for setting the page width and centering it and wouldn't nest it inside another .container.

@mdo
Copy link
Member

mdo commented Dec 1, 2013

@carasmo Yeah, something more specific would be nice come v4. Until then, not much to do since negative margin for the nesting would probably screw up some lives 😆.

@mdo
Copy link
Member

mdo commented Dec 1, 2013

Okay, closing this out since containers have actually never nested "properly" since v3. Here's the lowdown one more time:

  • We used to use max-width on .containers. That screwed up IE8, so we switched to width.
  • Since we were using max-width, the nested containers never stayed their intended width—they were always 30px short (the 15px gutters on either side via padding).
  • Using width, the nested containers are never short—they're always the correct width, which is where the problem lies for a few situations.

We could scope the width for IE8 only, but that just makes for an even worse edge case. For the time being, we're not going to support those nested containers. If you do wish to use them, add the negative margin as shown in this demo I put together: http://jsbin.com/IhEZadu/1.

@mdo mdo closed this as completed Dec 1, 2013
@rwgodfrey
Copy link
Author

Agree with the conclusion, and as mentioned earlier I ended up refactoring my site to remove the nested containers. However, the DOCS should probably be updated to explicitly state that nested containers aren't supported.

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2013

Reopening as a docs bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants
@mdo @cvrebert @carasmo @zlatanvasovic @MarcioBarrientos @rwgodfrey and others