_spacing.scss 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // stylelint-disable declaration-no-important
  2. // Margin and Padding
  3. @each $breakpoint in map-keys($grid-breakpoints) {
  4. @include media-breakpoint-up($breakpoint) {
  5. $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  6. @each $prop, $abbrev in (margin: m, padding: p) {
  7. @each $size, $length in $spacers {
  8. .#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length !important; }
  9. .#{$abbrev}t#{$infix}-#{$size},
  10. .#{$abbrev}y#{$infix}-#{$size} {
  11. #{$prop}-top: $length !important;
  12. }
  13. .#{$abbrev}r#{$infix}-#{$size},
  14. .#{$abbrev}x#{$infix}-#{$size} {
  15. #{$prop}-right: $length !important;
  16. }
  17. .#{$abbrev}b#{$infix}-#{$size},
  18. .#{$abbrev}y#{$infix}-#{$size} {
  19. #{$prop}-bottom: $length !important;
  20. }
  21. .#{$abbrev}l#{$infix}-#{$size},
  22. .#{$abbrev}x#{$infix}-#{$size} {
  23. #{$prop}-left: $length !important;
  24. }
  25. }
  26. }
  27. // Negative margins (e.g., where `.mb-n1` is negative version of `.mb-1`)
  28. @each $size, $length in $spacers {
  29. @if $size != 0 {
  30. .m#{$infix}-n#{$size} { margin: -$length !important; }
  31. .mt#{$infix}-n#{$size},
  32. .my#{$infix}-n#{$size} {
  33. margin-top: -$length !important;
  34. }
  35. .mr#{$infix}-n#{$size},
  36. .mx#{$infix}-n#{$size} {
  37. margin-right: -$length !important;
  38. }
  39. .mb#{$infix}-n#{$size},
  40. .my#{$infix}-n#{$size} {
  41. margin-bottom: -$length !important;
  42. }
  43. .ml#{$infix}-n#{$size},
  44. .mx#{$infix}-n#{$size} {
  45. margin-left: -$length !important;
  46. }
  47. }
  48. }
  49. // Some special margin utils
  50. .m#{$infix}-auto { margin: auto !important; }
  51. .mt#{$infix}-auto,
  52. .my#{$infix}-auto {
  53. margin-top: auto !important;
  54. }
  55. .mr#{$infix}-auto,
  56. .mx#{$infix}-auto {
  57. margin-right: auto !important;
  58. }
  59. .mb#{$infix}-auto,
  60. .my#{$infix}-auto {
  61. margin-bottom: auto !important;
  62. }
  63. .ml#{$infix}-auto,
  64. .mx#{$infix}-auto {
  65. margin-left: auto !important;
  66. }
  67. }
  68. }