How does bootstrap collapse columns at a certain viewport width using only css? -
how bootstrap change applying col-sm-* col-xs-* when viewport width passes boundary (if width>768, apply sm, else apply xs).
<div class="container"> <div class="row"> <!-- navigation --> <div class="col-sm-2 col-xs-12"> <ul class="nav nav-pills nav-stacked"> <li><a href="">manage projects</a></li> <li><a href="">billing</a></li> <li><a href="">account settings</a></li> </ul> </div> <!-- view --> <div class="col-sm-10 col-xs-12"> view </div> </div> </div>
in bootstrap.css, see if @media(min-width>768) sets col-sm-* width's , float-left, see col-xs-* should ignored.
in particular, see if window getting bigger, how setting col-sm-* might override col-xs-* (maybe qwirk of browsers - last attribute applied 1 rendered), if window getting smaller, col-sm-* never told not applied, if makes sense.
as pointed out in comments, bootstrap designed "mobile first" means styled first mobile screens, , additional styles added in screen gets larger. done through use of css media queries, using min-width
conditions.
these min-width
media queries add styles within them page once browser exceeds minimum width. additionally, getting @ in question, css in fact use last style applied, when same style applied more once (this assumes both styles have same selector weighting, that's whole separate topic)
with these 2 things in mind, if inspect column elements, see when browser large, col-xs-*
class getting applied, being overridden col-sm-*
class. because class's order in css comes after other one, giving priority. however, once browser's width drops below point, media query removes styles page, allowing col-xs-*
class regain it's precedence.
let me know if you'd me explain more in-depth, , i'll see can do.
Comments
Post a Comment