|
1 |
| ---- |
| 1 | +atom--- |
2 | 2 | layout: docs
|
3 | 3 | title: Grid system
|
4 | 4 | group: layout
|
@@ -33,14 +33,14 @@ Sounds good? Great, let's move on to seeing all that in an example.
|
33 | 33 | If you're using Bootstrap's compiled CSS, this the example you'll want to start with.
|
34 | 34 |
|
35 | 35 | {% example html %}
|
36 |
| -<div class="container"> |
| 36 | +<div class="container">a |
37 | 37 | <div class="row">
|
38 | 38 | <div class="col-sm-4">
|
39 |
| - One of three columns |
| 39 | + One of three columnsa |
40 | 40 | </div>
|
41 | 41 | <div class="col-sm-4">
|
42 | 42 | One of three columns
|
43 |
| - </div> |
| 43 | + </div>atom |
44 | 44 | <div class="col-sm-4">
|
45 | 45 | One of three columns
|
46 | 46 | </div>
|
@@ -139,7 +139,15 @@ Variables and maps determine the number of columns, the gutter width, and the me
|
139 | 139 |
|
140 | 140 | {% highlight scss %}
|
141 | 141 | $grid-columns: 12;
|
142 |
| -$grid-gutter-width: 30px; |
| 142 | +$grid-gutter-width-base: 30px; |
| 143 | + |
| 144 | +$grid-gutter-widths: ( |
| 145 | + xs: $grid-gutter-width-base, // 30px |
| 146 | + sm: $grid-gutter-width-base, // 30px |
| 147 | + md: $grid-gutter-width-base, // 30px |
| 148 | + lg: $grid-gutter-width-base, // 30px |
| 149 | + xl: $grid-gutter-width-base // 30px |
| 150 | +) |
143 | 151 |
|
144 | 152 | $grid-breakpoints: (
|
145 | 153 | // Extra small screen / phone
|
@@ -168,30 +176,42 @@ Mixins are used in conjunction with the grid variables to generate semantic CSS
|
168 | 176 |
|
169 | 177 | {% highlight scss %}
|
170 | 178 | // Creates a wrapper for a series of columns
|
171 |
| -@mixin make-row($gutter: $grid-gutter-width) { |
| 179 | +@mixin make-row($gutters: $grid-gutter-widths) { |
172 | 180 | @if $enable-flex {
|
173 | 181 | display: flex;
|
174 | 182 | flex-wrap: wrap;
|
175 | 183 | } @else {
|
176 | 184 | @include clearfix();
|
177 | 185 | }
|
178 |
| - margin-left: ($gutter / -2); |
179 |
| - margin-right: ($gutter / -2); |
| 186 | + |
| 187 | + @each $breakpoint in map-keys($gutters) { |
| 188 | + @include media-breakpoint-up($breakpoint) { |
| 189 | + $gutter: map-get($gutters, $breakpoint); |
| 190 | + margin-right: ($gutter / -2); |
| 191 | + margin-left: ($gutter / -2); |
| 192 | + } |
| 193 | + } |
180 | 194 | }
|
181 | 195 |
|
182 | 196 | // Make the element grid-ready (applying everything but the width)
|
183 |
| -@mixin make-col-ready($gutter: $grid-gutter-width) { |
| 197 | +@mixin make-col-ready($gutters: $grid-gutter-widths) { |
184 | 198 | position: relative;
|
185 | 199 | min-height: 1px; // Prevent collapsing
|
186 |
| - padding-right: ($gutter / 2); |
187 |
| - padding-left: ($gutter / 2); |
188 | 200 |
|
189 | 201 | // Prevent columns from becoming too narrow when at smaller grid tiers by
|
190 | 202 | // always setting `width: 100%;`. This works because we use `flex` values
|
191 | 203 | // later on to override this initial width.
|
192 | 204 | @if $enable-flex {
|
193 | 205 | width: 100%;
|
194 | 206 | }
|
| 207 | + |
| 208 | + @each $breakpoint in map-keys($gutters) { |
| 209 | + @include media-breakpoint-up($breakpoint) { |
| 210 | + $gutter: map-get($gutters, $breakpoint); |
| 211 | + padding-right: ($gutter / 2); |
| 212 | + padding-left: ($gutter / 2); |
| 213 | + } |
| 214 | + } |
195 | 215 | }
|
196 | 216 |
|
197 | 217 | @mixin make-col($size, $columns: $grid-columns) {
|
@@ -463,11 +483,18 @@ Using our built-in grid Sass variables and maps, it's possible to completely cus
|
463 | 483 |
|
464 | 484 | ### Columns and gutters
|
465 | 485 |
|
466 |
| -The number of grid columns and their horizontal padding (aka, gutters) can be modified via Sass variables. `$grid-columns` is used to generate the widths (in percent) of each individual column while `$grid-gutter-width` is divided evenly across `padding-left` and `padding-right` for the column gutters. |
| 486 | +The number of grid columns and their horizontal padding (aka, gutters) can be modified via Sass variables. `$grid-columns` is used to generate the widths (in percent) of each individual column while `$grid-gutter-widths` allows breakpoint-specific widths that are divided evenly across `padding-left` and `padding-right` for the column gutters. |
467 | 487 |
|
468 | 488 | {% highlight scss %}
|
469 |
| -$grid-columns: 12; |
470 |
| -$grid-gutter-width: 30px; |
| 489 | +$grid-columns: 12 !default; |
| 490 | +$grid-gutter-width-base: 30px !default; |
| 491 | +$grid-gutter-widths: ( |
| 492 | + xs: $grid-gutter-width-base, |
| 493 | + sm: $grid-gutter-width-base, |
| 494 | + md: $grid-gutter-width-base, |
| 495 | + lg: $grid-gutter-width-base, |
| 496 | + xl: $grid-gutter-width-base |
| 497 | +) !default; |
471 | 498 | {% endhighlight %}
|
472 | 499 |
|
473 | 500 | ### Grid tiers
|
|
0 commit comments