_grid.scss 2.44 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
  margin-left:  ($gutter / -2);
  margin-right: ($gutter / -2);
}

Allan Chau's avatar
Allan Chau committed
36
@mixin make-col-ready($columns: $grid-columns, $gutter: $grid-gutter-width) {
Mark Otto's avatar
Mark Otto committed
37
  position: relative;
38
  min-height: 1px; // Prevent collapsing
39
40
  padding-right: ($gutter / 2);
  padding-left:  ($gutter / 2);
41

42
43
44
45
46
47
48
49
50
  // Prevent columns from becoming too narrow when at smaller grid tiers by
  // always setting `width: 100%;`. This works because we use `flex` values
  // later on to override this initial width.
  @if $enable-flex {
    width: 100%;
  }
}

@mixin make-col($size, $columns: $grid-columns, $gutter: $grid-gutter-width) {
51
52
  @if $enable-flex {
    flex: 0 0 percentage($size / $columns);
53
54
55
    // 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.
56
    max-width: percentage($size / $columns);
57
  } @else {
58
    float: left;
59
60
    width: percentage($size / $columns);
  }
Mark Otto's avatar
Mark Otto committed
61
62
}

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

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

Gleb Mazovetskiy's avatar
Gleb Mazovetskiy committed
71
72
73
74
75
76
77
78
79
80
81
82
83
@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
84
}