My understanding is that all Bootstrap-styled elements must exist inside a <div class="container">
element. But sometimes I see Bootstrap examples where there are multiple "containers":
<div class="container"> <!-- Blah, GUI stuff, blah --> </div> ... <div class="container"> <!-- Blah, more GUI stuff, blah --> </div>
My questions:
Docs: Bootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers to use in your projects.
Bootstrap comes with three different containers: .container , which sets a max-width at each responsive breakpoint. .container-fluid , which is width: 100% at all breakpoints. .container-{breakpoint} , which is width: 100% until the specified breakpoint.
Its is not illegal to use multiple containers. You can use as many as you want. e.g if you want to have multiple sections on a page with different background image or color, you can use sections and within each section you can use a container.
Some sections of the page will span the full viewport width and others won't. Some backgrounds will be the full width but the content won't.
An example of this is a featurette area which has a background image or color that is the full width of the viewport but the content inside that, forms or whatever, don't exceed the .container
at any given viewport width.
You don't nest .container
or .container-fluid
-- see the docs. It's not necessary.
Docs: Bootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers to use in your projects. Note that, due to padding and more, neither container is nestable [neither means that .container and .container-fluid are NOT to be nested].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With