In this page on the Bootstrap 3 documentation regarding the grid system (in the grid options table): http://getbootstrap.com/css/#grid-options
It says the following: Grid behaviour: Horizontal at all times, Collapsed to start, horizontal above breakpoints
Can someone please explain what this means, perhaps even with an example?
Thanks!
Bootstrap is a free, open source HTML, CSS, and JavaScript framework for quickly building responsive websites. Initially, Bootstrap was called Twitter Blueprint and was developed by a team working at Twitter.
Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. show) is triggered at the start of an event, and its past participle form (ex. shown) is triggered on the completion of an action. As of 3.0.0, all Bootstrap events are namespaced.
Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict and namespaced events, there may be compatibility problems that you need to fix on your own. For simple transition effects, include transition.js once alongside the other JS files.
Plugins can be included individually (using Bootstrap's individual *.js files), or all at once (using bootstrap.js or the minified bootstrap.min.js ). Both bootstrap.js and bootstrap.min.js contain all plugins in a single file. Include only one. Some plugins and CSS components depend on other plugins.
"Horizontal at all times" applies to extra small column (.col-xs
):
Code Sample:
<div class="row show-grid">
<div class="col-xs-6">.col-xs-6</div>
<div class="col-xs-6">.col-xs-6</div>
<div class="col-xs-3">.col-xs-3</div>
</div>
"Collapsed to start, horizontal above breakpoints" applies to small (sm
), medium (md
) and large (lg
) column classes:
You can try it on the examples in the documentation (on your link) by reducing your browser width.
It's the worst definition in the history!
Definition:
Collapsed to start
what they want to say is
column width 12/12
Definition:
horizontal above breakpoints
what they want to say is
when the screen reaches a certain width (breakpoint) columns become x/12 percentages according to classes used per column otherwise, remains 12/12
What they don't say is that they implement a waterfall -aka cascading- model of ccs media queries:
is the screen small? apply rules for small screens
is the screen medium? apply rules for medium screens
is the screen large? apply rules for large screens
If in your implementation of such a grid system you don't define an upper limit in each and every query then for a large screen ALL queries will apply with the winner be the last (a waterfall model)!
Of course in such a "nonsense(?)" - of no upper limits- the next query should overwrite the rules of it's ancestor meaning endless duplicate code!
In bootstrap there is no upper limit in it's queries so writing sth like:
<div class="col-xs-6 col-sm-8"></div>
<div class="col-xs-6"></div>
we can see 2 equal columns in phones (<768) and 2 stacked columns in small (>768) devices and beyond.
But why? Because there is a class col-sm-8
for the first column but for the missing rule in the second one the waterfall model has already applied width 6/12! (follow the questions of media queries above: a small screen is certainly extra small, a medium is certainly extra small and small etc.).
On the other hand if the developer had implemented queries in both sizes (upper & lower) the column No.2 would be undefined without proper class and that means would remain 12/12 in the mobile-first approach!
Bottom line, designers have to give fewer classes in their grids when no-upper limits exist in media queries but the behavior is not that intuitive!
It means if you use the col-xs classes, your grid will be horizontal on all screens, while if you use the col-sm, col-md, col-lg classes, it will be horizontal on screen widths greater than 768px,992px,1170px respectively, else they will be collapsed.
As an example, look at Example: Stacked-to-horizontal on the same page and resize your browser. The grid uses the col-md class. You'll notice that the grid stays horizontal as long as the viewport width is >992px, below which it is collapsed.
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