_spacing.scss 2.06 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
1
2
// stylelint-disable declaration-no-important

3
// Margin and Padding
4

5
@each $breakpoint in map-keys($grid-breakpoints) {
6
7
  @include media-breakpoint-up($breakpoint) {
    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
8

9
    @each $prop, $abbrev in (margin: m, padding: p) {
Starsam80's avatar
Starsam80 committed
10
      @each $size, $length in $spacers {
11
        .#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length !important; }
12
13
14
15
16
        .#{$abbrev}t#{$infix}-#{$size},
        .#{$abbrev}y#{$infix}-#{$size} {
          #{$prop}-top: $length !important;
        }
        .#{$abbrev}r#{$infix}-#{$size},
17
        .#{$abbrev}x#{$infix}-#{$size} {
Starsam80's avatar
Starsam80 committed
18
          #{$prop}-right: $length !important;
19
        }
20
        .#{$abbrev}b#{$infix}-#{$size},
21
        .#{$abbrev}y#{$infix}-#{$size} {
Starsam80's avatar
Starsam80 committed
22
          #{$prop}-bottom: $length !important;
23
        }
24
25
26
27
        .#{$abbrev}l#{$infix}-#{$size},
        .#{$abbrev}x#{$infix}-#{$size} {
          #{$prop}-left: $length !important;
        }
28
      }
29
    }
Mark Otto's avatar
Mark Otto committed
30

31
32
33
34
35
36
37
    // Negative margins (e.g., where `.mb-n1` is negative version of `.mb-1`)
    @each $size, $length in $spacers {
      @if not $size == 0 {
        .m#{$infix}-n#{$size} { margin: -$length !important; }
        .mt#{$infix}-n#{$size},
        .my#{$infix}-n#{$size} {
          margin-top: -$length !important;
38
        }
39
40
41
        .mr#{$infix}-n#{$size},
        .mx#{$infix}-n#{$size} {
          margin-right: -$length !important;
42
        }
43
44
45
        .mb#{$infix}-n#{$size},
        .my#{$infix}-n#{$size} {
          margin-bottom: -$length !important;
46
        }
47
48
49
        .ml#{$infix}-n#{$size},
        .mx#{$infix}-n#{$size} {
          margin-left: -$length !important;
50
51
52
53
        }
      }
    }

54
    // Some special margin utils
55
    .m#{$infix}-auto { margin: auto !important; }
56
57
58
59
60
    .mt#{$infix}-auto,
    .my#{$infix}-auto {
      margin-top: auto !important;
    }
    .mr#{$infix}-auto,
Mark Otto's avatar
Mark Otto committed
61
62
63
    .mx#{$infix}-auto {
      margin-right: auto !important;
    }
64
    .mb#{$infix}-auto,
Mark Otto's avatar
Mark Otto committed
65
    .my#{$infix}-auto {
66
      margin-bottom: auto !important;
Mark Otto's avatar
Mark Otto committed
67
    }
68
69
70
71
    .ml#{$infix}-auto,
    .mx#{$infix}-auto {
      margin-left: auto !important;
    }
Mark Otto's avatar
Mark Otto committed
72
  }
73
}