_grid.scss 2.18 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
2
3
4
5
6
/// Grid system
//
// Generate semantic grid columns with these mixins.

@mixin make-container($gutter: $grid-gutter-width) {
  margin-left: auto;
7
  margin-right: auto;
Mark Otto's avatar
Mark Otto committed
8
9
  padding-left:  ($gutter / 2);
  padding-right: ($gutter / 2);
vsn4ik's avatar
vsn4ik committed
10
  @if not $enable-flex {
11
12
    @include clearfix();
  }
Mark Otto's avatar
Mark Otto committed
13
14
}

15
16

// For each breakpoint, define the maximum width of the container in a media query
17
@mixin make-container-max-widths($max-widths: $container-max-widths, $breakpoints: $grid-breakpoints) {
18
  @each $breakpoint, $container-max-width in $max-widths {
19
    @include media-breakpoint-up($breakpoint, $breakpoints) {
20
21
22
23
24
      max-width: $container-max-width;
    }
  }
}

Mark Otto's avatar
Mark Otto committed
25
@mixin make-row($gutter: $grid-gutter-width) {
26
27
28
  @if $enable-flex {
    display: flex;
    flex-wrap: wrap;
29
30
  } @else {
    @include clearfix();
31
  }
Mark Otto's avatar
Mark Otto committed
32
33
34
35
36
37
  margin-left:  ($gutter / -2);
  margin-right: ($gutter / -2);
}

@mixin make-col($gutter: $grid-gutter-width) {
  position: relative;
38
39
40
  @if $enable-flex {
    flex: 1;
  } @else {
41
42
    float: left;
  }
Mark Otto's avatar
Mark Otto committed
43
44
45
46
47
  min-height: 1px;
  padding-left:  ($gutter / 2);
  padding-right: ($gutter / 2);
}

Gleb Mazovetskiy's avatar
Gleb Mazovetskiy committed
48
@mixin make-col-span($size, $columns: $grid-columns) {
49
50
  @if $enable-flex {
    flex: 0 0 percentage($size / $columns);
51
52
53
    // Add a `max-width` to ensure content within each column does not blow out
    // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
    // do not appear to require this.
54
    max-width: percentage($size / $columns);
55
56
57
  } @else {
    width: percentage($size / $columns);
  }
Mark Otto's avatar
Mark Otto committed
58
59
}

Gleb Mazovetskiy's avatar
Gleb Mazovetskiy committed
60
61
@mixin make-col-offset($size, $columns: $grid-columns) {
  margin-left: percentage($size / $columns);
Mark Otto's avatar
Mark Otto committed
62
63
}

Gleb Mazovetskiy's avatar
Gleb Mazovetskiy committed
64
65
@mixin make-col-push($size, $columns: $grid-columns) {
  left: if($size > 0, percentage($size / $columns), auto);
Mark Otto's avatar
Mark Otto committed
66
67
}

Gleb Mazovetskiy's avatar
Gleb Mazovetskiy committed
68
69
70
71
72
73
74
75
76
77
78
79
80
@mixin make-col-pull($size, $columns: $grid-columns) {
  right: if($size > 0, percentage($size / $columns), auto);
}

@mixin make-col-modifier($type, $size, $columns) {
  // Work around the lack of dynamic mixin @include support (https://github.com/sass/sass/issues/626)
  @if $type == push {
    @include make-col-push($size, $columns);
  } @else if $type == pull {
    @include make-col-pull($size, $columns);
  } @else if $type == offset {
    @include make-col-offset($size, $columns);
  }
Mark Otto's avatar
Mark Otto committed
81
}