Skip to content

Grid

/// Grid
// ––––––––––––––––––––––––––––––––––––––––––––––––––

// The main mixins used to create the grid containers, rows and columns

// used in .container and .container-fluid
//
@mixin make-container() {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: ($grid-gutter-width / 2);
  padding-left: ($grid-gutter-width / 2);
}

// For each breakpoint, define the maximum width of the container
//
@mixin make-container-max-widths($max-widths: $container-max-widths, $breakpoints: $grid-breakpoints) {
  @each $breakpoint, $container-max-width in $max-widths {
    @include media-breakpoint-up($breakpoint, $breakpoints) {
      max-width: $container-max-width;
    }
  }
}

// make a grid row
//
@mixin make-row($gutter: $grid-gutter-width) {
  display: flex;
  flex-wrap: wrap;
  margin-right: -$gutter / 2;
  margin-left: -$gutter / 2;
}

// make a grid column
//
// $size: number of columns wide
// $columns: number of columns in the row
//
@mixin make-col($size, $columns: $grid-columns) {
  flex: 0 0 percentage($size / $columns);
  // Add a `max-width` to ensure content within each column does not blow out
  // the width of the column. Applies to IE10+ and Firefox.
  max-width: percentage($size / $columns);
}

// make a grid column offset
//
// $size: number of columns to offset
// $columns: number of columns in the row
//
@mixin make-col-offset($size, $columns: $grid-columns) {
  $num: $size / $columns;

  margin-left: if($num == 0, 0, percentage($num));
}