css - What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap? -
what difference among col-lg-*
, col-md-*
, col-sm-*
in twitter bootstrap 3?
the bootstrap 3 grid comes in 4 tiers (or "breakpoints")...
- extra small (for smartphones
.col-xs-*
) - small (for tablets
.col-sm-*
) - medium (for laptops
.col-md-*
) - large (for laptops/desktops
.col-lg-*
).
these grid sizes enable control grid behavior on different widths. different tiers controlled css media queries.
so in bootstrap's 12-column grid...
col-sm-3
3 of 12 columns wide (25%) on typical small device width (> 768 pixels)
col-md-3
3 of 12 columns wide (25%) on typical medium device width (> 992 pixels)
the smallest tier set (xs
, sm
or md
) defines size larger screen widths. so, same size column on tiers, set width smallest viewport...
<div class="col-lg-3 col-md-3 col-sm-3">..</div>
same as,
<div class="col-sm-3">..</div>
because col-sm-3
means 3 units on sm , up
, unless overridden larger tier.
xs
(default) > overridden sm
> overridden md
> overridden lg
combine classes use change column widths on different grid sizes. creates responsive layout.
<div class="col-md-3 col-sm-6">..</div>
the sm
, md
, lg
grids "stack" vertically on screens/viewports less 768 pixels. xs
grid fits in. columns use col-xs-*
classes not stack vertically, , continue scale down on smallest screens.
resize browser using demo , you'll see grid scaling effects.
update bootstrap 4 there new -xl-
size, see this demo. -xs-
infix has been removed, smallest columns col-1
, col-2
.. col-12
, etc..
also, article explains more bootstrap grid
wiki
Comments
Post a Comment