sass/mixins/_grid.scss
/// Grid system
//

@mixin make-container() {
  //width: 100%; // 因为有padding
  margin-left: auto;
  margin-right: auto;
  padding-left: ($grid-gutter-width / 2);
  padding-right: ($grid-gutter-width / 2);
}

@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;
    }
  }  
}

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

@mixin make-col-ready() {
  position: relative;
  width: 100%;
  min-height: 1px;
  padding-right: ($grid-gutter-width / 2);
  padding-left:  ($grid-gutter-width / 2);
}

@mixin make-col($size, $columns: $grid-columns) {
  flex: 0 0 percentage($size / $columns);
  max-width: percentage($size / $columns);
}

@mixin make-col-offset($size, $columns: $grid-columns) {
  margin-left: percentage($size / $columns);
}

/// Grid layout-core
@mixin make-grid-columns($columns: $grid-columns, $gutter: $grid-gutter-width, $breakpoints: $grid-breakpoints) {
  %grid-column {
    //position: relative;
    width: 100%;
    min-height: 1px;
    padding-right: ($gutter / 2);
    padding-left:  ($gutter / 2);
  }

  @each $breakpoint in map-keys($breakpoints) {
    $infix: breakpoint-infix($breakpoint, $breakpoints);

    // Allow columns to stretch full width below their breakpoints
    @for $i from 1 through $columns {
      .#{$prefix}col#{$infix}-#{$i} {
        @extend %grid-column;
      }
    }
    .#{$prefix}col#{$infix},
    .#{$prefix}col#{$infix}-auto {
      @extend %grid-column;
    }

    @include media-breakpoint-up($breakpoint, $breakpoints) {
      .#{$prefix}col#{$infix} {
        flex-basis: 0;
        flex-grow: 1;
        max-width: 100%;
      }
      .#{$prefix}col#{$infix}-auto {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
      }

      @for $i from 1 through $columns {
        .#{$prefix}col#{$infix}-#{$i} {
          @include make-col($i, $columns);
        }
      }

      @for $i from 1 through $columns {
        .#{$prefix}order#{$infix}-#{$i} {
          order: $i;
        }
      }

      @for $i from 0 through ($columns - 1) {
        @if not ($infix == "" and $i == 0) { // 允许offset后缀为空或为0
          .#{$prefix}offset#{$infix}-#{$i} {
            @include make-col-offset($i, $columns)
          }
        }
      }
    }
  }
}
