diff options
| author | Mark Otto <[email protected]> | 2016-09-15 10:20:57 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-09-15 10:20:57 -0700 |
| commit | 64dcb8b5073293daa911d2b274fd875f31693317 (patch) | |
| tree | 112821f9bdd9b51f8953521cc2f34a537ccf74a2 /docs/layout/grid.md | |
| parent | 15f522fd4ae3fe7933d526f045b0b2df22a35291 (diff) | |
| parent | 63129112bbea91f7cd62014f162f857f50084656 (diff) | |
| download | bootstrap-64dcb8b5073293daa911d2b274fd875f31693317.tar.xz bootstrap-64dcb8b5073293daa911d2b274fd875f31693317.zip | |
Merge branch 'v4-dev' into v4-navbars
Diffstat (limited to 'docs/layout/grid.md')
| -rw-r--r-- | docs/layout/grid.md | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/docs/layout/grid.md b/docs/layout/grid.md index 8e7c5225e..5b68053aa 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -139,7 +139,7 @@ Variables and maps determine the number of columns, the gutter width, and the me {% highlight scss %} $grid-columns: 12; -$grid-gutter-width: 15px; +$grid-gutter-width: 30px; $grid-breakpoints: ( // Extra small screen / phone @@ -180,7 +180,7 @@ Mixins are used in conjunction with the grid variables to generate semantic CSS } // Make the element grid-ready (applying everything but the width) -@mixin make-col-ready($size, $columns: $grid-columns, $gutter: $grid-gutter-width) { +@mixin make-col-ready($gutter: $grid-gutter-width) { position: relative; min-height: 1px; // Prevent collapsing padding-right: ($gutter / 2); @@ -194,7 +194,7 @@ Mixins are used in conjunction with the grid variables to generate semantic CSS } } -@mixin make-col($size, $columns: $grid-columns, $gutter: $grid-gutter-width) { +@mixin make-col($size, $columns: $grid-columns) { @if $enable-flex { flex: 0 0 percentage($size / $columns); // Add a `max-width` to ensure content within each column does not blow out @@ -208,14 +208,16 @@ Mixins are used in conjunction with the grid variables to generate semantic CSS } // Get fancy by offsetting, or changing the sort order -@mixin make-col-offset($columns) { - margin-left: percentage(($columns / $grid-columns)); +@mixin make-col-offset($size, $columns: $grid-columns) { + margin-left: percentage($size / $columns); } -@mixin make-col-push($columns) { - left: percentage(($columns / $grid-columns)); + +@mixin make-col-push($size, $columns: $grid-columns) { + left: if($size > 0, percentage($size / $columns), auto); } -@mixin make-col-pull($columns) { - right: percentage(($columns / $grid-columns)); + +@mixin make-col-pull($size, $columns: $grid-columns) { + right: if($size > 0, percentage($size / $columns), auto); } {% endhighlight %} @@ -270,36 +272,36 @@ In addition to our semantic mixins, Bootstrap includes an extensive set of prebu ### Example: Stacked-to-horizontal -Using a single set of `.col-md-*` grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices. Place grid columns with the `.col` base class and a modifier within any `.row`. +Using a single set of `.col-md-*` grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices. Place grid columns within any `.row`. <div class="bd-example-row"> {% example html %} <div class="row"> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> - <div class="col-md-1">md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> + <div class="col-md-1">col-md-1</div> </div> <div class="row"> - <div class="col-md-8">md-8</div> - <div class="col-md-4">md-4</div> + <div class="col-md-8">col-md-8</div> + <div class="col-md-4">col-md-4</div> </div> <div class="row"> - <div class="col-md-4">md-4</div> - <div class="col-md-4">md-4</div> - <div class="col-md-4">md-4</div> + <div class="col-md-4">col-md-4</div> + <div class="col-md-4">col-md-4</div> + <div class="col-md-4">col-md-4</div> </div> <div class="row"> - <div class="col-md-6">md-6</div> - <div class="col-md-6">md-6</div> + <div class="col-md-6">col-md-6</div> + <div class="col-md-6">col-md-6</div> </div> {% endexample %} </div> @@ -459,7 +461,18 @@ Easily change the order of our built-in grid columns with `.push-md-*` and `.pul Using our built-in grid Sass variables and maps, it's possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, and the container widths—then recompile. -For example, if you wanted just three grid tiers, you'd update the `$grid-breakpoints` and `$container-max-widths` to something like this: +### Columns and gutters + +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. + +{% highlight scss %} +$grid-columns: 12; +$grid-gutter-width: 30px; +{% endhighlight %} + +### Grid tiers + +Moving beyond the columns themselves, you may also customize the number of grid tiers. If you wanted just three grid tiers, you'd update the `$grid-breakpoints` and `$container-max-widths` to something like this: {% highlight scss %} $grid-breakpoints: ( @@ -475,4 +488,4 @@ $container-max-widths: ( ); {% endhighlight %} -Save your changes and recompile to have a brand new set of predefined grid classes for column widths, offsets, pushes, and pulls. Responsive visibility utilities will also be updated to use the custom breakpoints. +When making any changes to the Sass variables or maps, you'll need to save your changes and recompile. Doing so will out a brand new set of predefined grid classes for column widths, offsets, pushes, and pulls. Responsive visibility utilities will also be updated to use the custom breakpoints. |
