Overview

3 Containers

  • .container — sets a max-width at each responsive breakpoint
  • .container-<breakpoint> — uses width: 100% until the specified breakpoint
  • .container-fluid — sets width: 100% at all breakpoints

Comparison:

Extra small <576pxSmall ≥576pxMedium ≥768pxLarge ≥992pxX-Large ≥1200pxXX-Large ≥1400px
.container100%540px720px960px1140px
.container-sm100%540px720px960px1140px
.container-md100%100%720px960px1140px
.container-lg100%100%100%960px1140px
.container-xl100%100%100%100%1140px
.container-xxl100%100%100%100%100%
.container-fluid100%100%100%100%100%

Usage

Default container

<div class="container">
  <!-- Content here -->
</div>

Responsive containers

<div class="container-sm">100% wide until small breakpoint</div>
<div class="container-md">100% wide until medium breakpoint</div>
<div class="container-lg">100% wide until large breakpoint</div>
<div class="container-xl">100% wide until extra large breakpoint</div>
<div class="container-xxl">100% wide until extra extra large breakpoint</div>

Fluid containers

<div class="container-fluid">
  ...
</div>

Customize

In scss/_variables.css:

$container-max-widths: (
  sm: 540px,
  md: 720px,
  lg: 960px,
  xl: 1140px,
  xxl: 1320px
);

Create custom mix-ins:

/* Source mixin */
@mixin make-container($padding-x: $container-padding-x) {
  width: 100%;
  padding-right: $padding-x;
  padding-left: $padding-x;
  margin-right: auto;
  margin-left: auto;
}

/* Usage */
.custom-container {
  @include make-container();
}