Table of Contents
Bullet Points
Use .container-fluid
for a full width container, spanning the entire width of the viewport.
Grid
Thanks to flexbox, grid columns without a specified width will automatically layout as equal width columns. For example, four instances of .col-sm will each automatically be 25% wide from the small breakpoint and up. See the auto-layout columns section for more examples.
Column classes indicate the number of columns you’d like to use out of the possible 12 per row. So, if you want three equal-width columns across, you can use .col-4.
Grid breakpoints are based on minimum width media queries, meaning they apply to that one breakpoint and all those above it (e.g., .col-sm-4 applies to small, medium, large, and extra large devices, but not the first xs breakpoint).
Grid Options
Extra small
<576px
Small
≥576px
Medium
≥768px
Large
≥992px
Extra large
≥1200px
Max container width
None (auto)
540px
720px
960px
1140px
Class prefix
.col-
.col-sm-
.col-md-
.col-lg-
.col-xl-
# of columns
12
Gutter width
30px (15px on each side of a column)
Nestable
Yes
Column ordering
Yes
// Extra small devices ( portrait phones , less than 576 px )
// No media query since this is the default in Bootstrap
// Small devices ( landscape phones , 576 px and up )
@media ( min-width : 576px ) { ... }
// Medium devices ( tablets , 768 px and up )
@media ( min-width : 768px ) { ... }
// Large devices ( desktops , 992 px and up )
@media ( min-width : 992px ) { ... }
// Extra large devices ( large desktops , 1200 px and up )
@media ( min-width : 1200px ) { ... }
Usage
@include media-breakpoint-up ( xs ) { ... }
@include media-breakpoint-up ( sm ) { ... }
@include media-breakpoint-up ( md ) { ... }
@include media-breakpoint-up ( lg ) { ... }
@include media-breakpoint-up ( xl ) { ... }
// Example usage :
@include media-breakpoint-up ( sm ) {
.some-class {
display : block ;
}
}
// Extra small devices ( portrait phones , less than 576 px )
@media ( max-width : 575.98px ) { ... }
// Small devices ( landscape phones , less than 768 px )
@media ( max-width : 767.98px ) { ... }
// Medium devices ( tablets , less than 992 px )
@media ( max-width : 991.98px ) { ... }
// Large devices ( desktops , less than 1200 px )
@media ( max-width : 1199.98px ) { ... }
// Extra large devices ( large desktops )
// No media query since the extra-large breakpoint has no upper bound on its width
Usage
@include media-breakpoint-down ( xs ) { ... }
@include media-breakpoint-down ( sm ) { ... }
@include media-breakpoint-down ( md ) { ... }
@include media-breakpoint-down ( lg ) { ... }
// Extra small devices ( portrait phones , less than 576 px )
@media ( max-width : 575.98px ) { ... }
// Small devices ( landscape phones , 576 px and up )
@media ( min-width : 576px ) and ( max-width : 767.98px ) { ... }
// Medium devices ( tablets , 768 px and up )
@media ( min-width : 768px ) and ( max-width : 991.98px ) { ... }
// Large devices ( desktops , 992 px and up )
@media ( min-width : 992px ) and ( max-width : 1199.98px ) { ... }
// Extra large devices ( large desktops , 1200 px and up )
@media ( min-width : 1200px ) { ... }
Usage
@include media-breakpoint-only ( xs ) { ... }
@include media-breakpoint-only ( sm ) { ... }
@include media-breakpoint-only ( md ) { ... }
@include media-breakpoint-only ( lg ) { ... }
@include media-breakpoint-only ( xl ) { ... }
Span Multiple Breakpoint Widths
// Example
// Apply styles starting from medium devices and up to extra large devices
@media ( min-width : 768px ) and ( max-width : 1199.98px ) { ... }
Usage:
@include media-breakpoint-between ( md , xl ) { ... }
Source: https://getbootstrap.com/docs/4.2/layout/grid/