diff --git a/scss/utilities/_spacing.scss b/scss/utilities/_spacing.scss index b2e2354b12..c43387dec1 100644 --- a/scss/utilities/_spacing.scss +++ b/scss/utilities/_spacing.scss @@ -8,7 +8,6 @@ @each $prop, $abbrev in (margin: m, padding: p) { @each $size, $length in $spacers { - .#{$abbrev}#{$infix}-#{$size} { #{$prop}: $length !important; } .#{$abbrev}t#{$infix}-#{$size}, .#{$abbrev}y#{$infix}-#{$size} { @@ -29,6 +28,29 @@ } } + // 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; + } + .mr#{$infix}-n#{$size}, + .mx#{$infix}-n#{$size} { + margin-right: -$length !important; + } + .mb#{$infix}-n#{$size}, + .my#{$infix}-n#{$size} { + margin-bottom: -$length !important; + } + .ml#{$infix}-n#{$size}, + .mx#{$infix}-n#{$size} { + margin-left: -$length !important; + } + } + } + // Some special margin utils .m#{$infix}-auto { margin: auto !important; } .mt#{$infix}-auto, diff --git a/site/docs/4.1/layout/grid.md b/site/docs/4.1/layout/grid.md index e697517d7c..1ee0893818 100644 --- a/site/docs/4.1/layout/grid.md +++ b/site/docs/4.1/layout/grid.md @@ -324,6 +324,20 @@ Don't want your columns to simply stack in some grid tiers? Use a combination of {% include example.html content=example %} +### Gutters + +Gutters can be responsively adjusted by breakpoint-specific padding and negative margin utility classes. To change the gutters in a given row, pair a negative margin utility on the `.row` and matching padding utilities on the `.col`s. + +Here's an example of customizing the Bootstrap grid at the large (`lg`) breakpoint and above. We've increased the `.col` padding with `.px-lg-5` and then counteracted that with `.mx-lg-n5` on the parent `.row`. + +{% capture example %} +