diff options
| author | Mark Otto <[email protected]> | 2016-12-04 21:05:19 -0800 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2016-12-04 21:05:19 -0800 |
| commit | 1e3ec8935520e2d118d9d7742abd80183d34beb2 (patch) | |
| tree | 3a2e940d7d91d578db4fe86675fa9d2a11bb9512 /docs/layout/grid.md | |
| parent | 6782dd6e92637f85e3778584ec417a775d01243f (diff) | |
| parent | 5a19d4870537ca85ba38beeb7eabe80858417b72 (diff) | |
| download | bootstrap-1e3ec8935520e2d118d9d7742abd80183d34beb2.tar.xz bootstrap-1e3ec8935520e2d118d9d7742abd80183d34beb2.zip | |
Merge branch 'v4-dev' into carousel
Diffstat (limited to 'docs/layout/grid.md')
| -rw-r--r-- | docs/layout/grid.md | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/docs/layout/grid.md b/docs/layout/grid.md index ea0a9862b..68d7f7020 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -22,7 +22,7 @@ At a high level, here's how the grid system works: - Content should be placed within columns, and only columns may be immediate children of rows. - Column classes indicate the number of columns you'd like to use out of the possible 12 per row. So if you want three equal-width columns, you'd use `.col-sm-4`. - Column `width`s are set in percentages, so they're always fluid and sized relative to their parent element. -- Columns have horizontal `padding` to create the gutters between individual columns. +- Columns have horizontal `padding` to create the gutters between individual columns, however, you can remove the `margin` from rows and `padding` from columns with `.no-gutters` on the `.row`. - There are five grid tiers, one for each [responsive breakpoint]({{ site.baseurl }}/layout/overview/#responsive-breakpoints): extra small, small, medium, large, and extra large. - Grid tiers are based on minimum widths, meaning they apply to that one tier and all those above it (e.g., `.col-sm-4` applies to small, medium, large, and extra large devices). - You can use predefined grid classes or Sass mixins for more semantic markup. @@ -62,23 +62,23 @@ See how aspects of the Bootstrap grid system work across multiple devices with a <thead> <tr> <th></th> - <th class="text-xs-center"> + <th class="text-center"> Extra small<br> <small><576px</small> </th> - <th class="text-xs-center"> + <th class="text-center"> Small<br> <small>≥576px</small> </th> - <th class="text-xs-center"> + <th class="text-center"> Medium<br> <small>≥768px</small> </th> - <th class="text-xs-center"> + <th class="text-center"> Large<br> <small>≥992px</small> </th> - <th class="text-xs-center"> + <th class="text-center"> Extra large<br> <small>≥1200px</small> </th> @@ -100,7 +100,7 @@ See how aspects of the Bootstrap grid system work across multiple devices with a </tr> <tr> <th class="text-nowrap" scope="row">Class prefix</th> - <td><code>.col-xs-</code></td> + <td><code>.col-</code></td> <td><code>.col-sm-</code></td> <td><code>.col-md-</code></td> <td><code>.col-lg-</code></td> @@ -329,7 +329,7 @@ Using a single set of `.col-md-*` grid classes, you can create a basic grid syst ### Example: Mobile and desktop -Don't want your columns to simply stack in smaller devices? Use the extra small and medium device grid classes by adding `.col-xs-*` and `.col-md-*` to your columns. See the example below for a better idea of how it all works. +Don't want your columns to simply stack in smaller devices? Use the extra small and medium device grid classes by adding `.col-*` and `.col-md-*` to your columns. See the example below for a better idea of how it all works. <div class="bd-example-row"> {% example html %} @@ -374,6 +374,36 @@ Build on the previous example by creating even more dynamic and powerful layouts {% endexample %} </div> +### Example: Remove gutters + +The gutters between columns in our default, predefined grid classes can be removed with `.no-gutters`. This removes the negative `margin`s from `.row` and the horizontal `padding` from all immediate children columns. + +Here's the source code for creating these styles. Note that column overrides are scoped to only the first children columns and are targeted via [attribute selector](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors). While this generates a more specific selector, column padding can still be further customized with [spacing utilities]({{ site.baseurl }}/utilities/spacing/). + +{% highlight sass %} +.no-gutters { + margin-right: 0; + margin-left: 0; + + > .col, + > [class*="col-"] { + padding-right: 0; + padding-left: 0; + } +} +{% endhighlight %} + +In practice, here's how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more). + +<div class="bd-example-row"> +{% example html %} +<div class="row no-gutters"> + <div class="col-12 col-sm-6 col-md-8">.col-12 .col-sm-6 .col-md-8</div> + <div class="col-6 col-md-4">.col-6 .col-md-4</div> +</div> +{% endexample %} +</div> + ### Example: Column wrapping If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line. |
