View on GitHub

Containers

Containers are a fundamental building block of Boosted that contain, pad, and align your content within a given device or viewport.

How they work

Containers are the most basic layout element in Boosted and are required when using our default grid system. Containers are used to contain, pad, and (sometimes) center the content within them. While containers can be nested, most layouts do not require a nested container.

Boosted comes with three different containers:

  • .container, which sets a static max-width between each responsive breakpoint
  • .container-{breakpoint}, which follow the .container-fluid behavior until the specified breakpoint, then it follows the .container one
    • .container-xxl is the one to use for Orange sites in order to be compliant with the Orange brand
  • .container-fluid, which sets the width: 100% and overrides max-width: 100vw - $breakpoint_margin at all breakpoints

The table below illustrates how each container’s max-width compares to the original .container and .container-fluid across each breakpoint.

See them in action and compare them in our Grid example.

Please note that we apply an extra-padding on our containers (see our mixins)

Extra small
<480px
Small
≥480px
Medium
≥768px
Large
≥1024px
X-Large
≥1280px
XX-Large
≥1440px
.container 312px 468px 744px 960px 1200px 1320px
.container-sm 100vw -
(2 * 4px)
468px 744px 960px 1200px 1320px
.container-md 100vw -
(2 * 4px)
100vw -
(2 * 6px)
744px 960px 1140px 1320px
.container-lg 100vw -
(2 * 4px)
100vw -
(2 * 6px)
100vw -
(2 * 12px)
960px 1140px 1320px
.container-xl 100vw -
(2 * 4px)
100vw -
(2 * 6px)
100vw -
(2 * 12px)
100vw -
(2 * 32px)
1140px 1320px
.container-xxl 100vw -
(2 * 4px)
100vw -
(2 * 6px)
100vw -
(2 * 12px)
100vw -
(2 * 32px)
100vw -
(2 * 40px)
1320px
.container-fluid 100vw -
(2 * 4px)
100vw -
(2 * 6px)
100vw -
(2 * 12px)
100vw -
(2 * 32px)
100vw -
(2 * 40px)
100vw -
(2 * 60px)

Default container

Our default .container class is a responsive, fixed-width container, meaning its max-width changes at each breakpoint.

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

Responsive containers

Responsive containers allow you to specify a class that follows the .container-fluid behavior until the specified breakpoint is reached, after which we apply max-widths for each of the higher breakpoints. For example, .container-sm behaves like the .container-fluid to start until the sm breakpoint is reached, where it will scale up with md, lg, xl, and xxl.

<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

Use .container-fluid for a full width container with minimum margins, spanning almost the entire width of the viewport.

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

Sass

Variables

As shown above, Boosted generates a series of predefined container classes to help you build the layouts you desire. You may customize these predefined container classes by modifying the Sass map (found in _variables.scss) that powers them:

$container-max-widths: (
  xs: 312px,
  sm: 468px,
  md: 744px,
  lg: 960px,
  xl: 1200px,
  xxl: 1320px
);

// Boosted mod
$container-fluid-margin: (
  xs: 4px,
  sm: 6px,
  md: 12px,
  lg: 32px,
  xl: 40px,
  xxl: 60px
);
// End mod

Mixins

In addition to customizing the Sass, you can also create your own containers with our Sass mixin.

@mixin make-container($gutter: $container-padding-x) {
  --#{$prefix}gutter-x: #{$gutter};
  --#{$prefix}gutter-y: 0;
  width: 100%;
  padding-right: calc(var(--#{$prefix}gutter-x) * .25); // stylelint-disable-line function-disallowed-list
  padding-left: calc(var(--#{$prefix}gutter-x) * .25); // stylelint-disable-line function-disallowed-list
  margin-right: auto;
  margin-left: auto;

  // Boosted mod: gutter depends on breakpoint
  // @note Needs both interpolation and parenthesis to prevent stylelint-scss/dimension-no-non-numeric-values to fail
  @include media-breakpoint-up($grid-gutter-breakpoint) {
    --#{$prefix}gutter-x: #{($gutter * 2)};
  }
  // End mod
}

// Boosted mod: fluid containers aren't full width → include margins
@mixin make-container-fluid-margin() {
  @each $breakpoint, $container-margin in $container-fluid-margin {
    @include media-breakpoint-up($breakpoint) {
      max-width: subtract(100vw, $container-margin * 2);
    }
  }
}
// End mod
// Usage
.custom-container {
  @include make-container();
}

For more information and examples on how to modify our Sass maps and variables, please refer to the Sass section of the Grid documentation.