]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Allow individual grid classes to override `.row-cols` (#33621)
authorAnal-Retentive Squirrel Hunter <43895102+lacutah@users.noreply.github.com>
Thu, 3 Jun 2021 16:18:00 +0000 (12:18 -0400)
committerGitHub <noreply@github.com>
Thu, 3 Jun 2021 16:18:00 +0000 (19:18 +0300)
scss/mixins/_grid.scss
site/content/docs/5.0/layout/grid.md

index d757eac7404ae08d6f4c38254b2d6cc93b9a0004..36031df7961ca3f84dc03c3fd28ec4caa8b4b40a 100644 (file)
@@ -65,8 +65,8 @@
 
 @mixin make-grid-columns($columns: $grid-columns, $gutter: $grid-gutter-width, $breakpoints: $grid-breakpoints) {
   @each $breakpoint in map-keys($breakpoints) {
+    // .row-cols defaults must all appear before .col overrides so they can be overridden.
     $infix: breakpoint-infix($breakpoint, $breakpoints);
-
     @include media-breakpoint-up($breakpoint, $breakpoints) {
       // Provide basic `.col-{bp}` classes for equal-width flexbox columns
       .col#{$infix} {
           }
         }
       }
+    }
+  }
 
+  @each $breakpoint in map-keys($breakpoints) {
+    $infix: breakpoint-infix($breakpoint, $breakpoints);
+
+    @include media-breakpoint-up($breakpoint, $breakpoints) {
       .col#{$infix}-auto {
         @include make-col-auto();
       }
index d0c7a80f7e2122b388618f4a34e956077869811f..afa3818a201de787eb7fca7a2f1d37c629d8bd10 100644 (file)
@@ -299,9 +299,9 @@ Don't want your columns to simply stack in some grid tiers? Use a combination of
 
 ### Row columns
 
-Use the responsive `.row-cols-*` classes to quickly set the number of columns that best render your content and layout. Whereas normal `.col-*` classes apply to the individual columns (e.g., `.col-md-4`), the row columns classes are set on the parent `.row` as a shortcut. With `.row-cols-auto` you can give the columns their natural width.
+Use the responsive `.row-cols-*` classes to quickly set the number of columns that best render your content and layout. Whereas normal `.col-*` classes apply to the individual columns (e.g., `.col-md-4`), the row columns classes are set on the parent `.row` as a default for contained columns. With `.row-cols-auto` you can give the columns their natural width.
 
-Use these row columns classes to quickly create basic grid layouts or to control your card layouts.
+Use these row columns classes to quickly create basic grid layouts or to control your card layouts and override when needed at the column level.
 
 {{< example class="bd-example-row" >}}
 <div class="container">
@@ -369,6 +369,25 @@ Use these row columns classes to quickly create basic grid layouts or to control
 </div>
 {{< /example >}}
 
+{{< example class="bd-example-row" >}}
+<div class="container">
+  <div class="row row-cols-2 row-cols-lg-3">
+    <div class="col">Column</div>
+    <div class="col">Column</div>
+    <div class="col">Column</div>
+    <div class="col">Column</div>
+    <div class="col">Column</div>
+    <div class="col">Column</div>
+    <div class="col-4 col-lg-2">Column</div>
+    <div class="col-4 col-lg-2">Column</div>
+    <div class="col-4 col-lg-2">Column</div>
+    <div class="col-4 col-lg-2">Column</div>
+    <div class="col-4 col-lg-2">Column</div>
+    <div class="col-4 col-lg-2">Column</div>
+  </div>
+</div>
+{{< /example >}}
+
 You can also use the accompanying Sass mixin, `row-cols()`:
 
 ```scss