From 29dcf9ac623c5ae13bd3d582b9e0b369ba7a3cc6 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 6 Feb 2016 00:23:52 -0800 Subject: Update grid mixins code snippets in the docs to include flexbox changes --- docs/layout/grid.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'docs/layout/grid.md') diff --git a/docs/layout/grid.md b/docs/layout/grid.md index c318f5330..f2427137f 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -164,23 +164,40 @@ Mixins are used in conjunction with the grid variables to generate semantic CSS {% highlight scss %} // Creates a wrapper for a series of columns @mixin make-row($gutter: $grid-gutter-width) { + @if $enable-flex { + display: flex; + flex-wrap: wrap; + } @else { + @include clearfix(); + } margin-left: ($gutter / -2); margin-right: ($gutter / -2); - @include clearfix(); } // Make the element grid-ready (applying everything but the width) @mixin make-col($gutter: $grid-gutter-width) { position: relative; - float: left; + @if $enable-flex { + flex: 1; + } @else { + float: left; + } min-height: 1px; padding-left: ($gutter / 2); padding-right: ($gutter / 2); } -// Set a width (to be used in or out of media queries) -@mixin make-col-span($columns) { - width: percentage(($columns / $grid-columns)); +@mixin make-col-span($size, $columns: $grid-columns) { + // Set a width (to be used in or out of media queries) + @if $enable-flex { + flex: 0 0 percentage($size / $columns); + // Add a `max-width` to ensure content within each column does not blow out + // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari + // do not appear to require this. + max-width: percentage($size / $columns); + } @else { + width: percentage($size / $columns); + } } // Get fancy by offsetting, or changing the sort order -- cgit v1.2.3 From a9e428a7287bd4c7e33e286979830137fc914587 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 6 Feb 2016 00:46:00 -0800 Subject: Update grid docs to include new required .col base class --- docs/layout/grid.md | 120 ++++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'docs/layout/grid.md') diff --git a/docs/layout/grid.md b/docs/layout/grid.md index c318f5330..029fcdfe2 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -35,13 +35,13 @@ If you're using Bootstrap's compiled CSS, this the example you'll want to start {% example html %}
-
+
One of three columns
-
+
One of three columns
-
+
One of three columns
@@ -246,36 +246,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 in 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 with the `.col` base class and a modifier within any `.row`.
{% example html %}
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
-
.col-md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
-
.col-md-8
-
.col-md-4
+
md-8
+
md-4
-
.col-md-4
-
.col-md-4
-
.col-md-4
+
md-4
+
md-4
+
md-4
-
.col-md-6
-
.col-md-6
+
md-6
+
md-6
{% endexample %}
@@ -288,21 +288,21 @@ Don't want your columns to simply stack in smaller devices? Use the extra small {% example html %}
-
.col-xs-12 .col-md-8
-
.col-xs-6 .col-md-4
+
.col .col-xs-12 .col-md-8
+
.col .col-xs-6 .col-md-4
-
.col-xs-6 .col-md-4
-
.col-xs-6 .col-md-4
-
.col-xs-6 .col-md-4
+
.col .col-xs-6 .col-md-4
+
.col .col-xs-6 .col-md-4
+
.col .col-xs-6 .col-md-4
-
.col-xs-6
-
.col-xs-6
+
.col .col-xs-6
+
.col .col-xs-6
{% endexample %}
@@ -314,15 +314,15 @@ Build on the previous example by creating even more dynamic and powerful layouts
{% example html %}
-
.col-xs-12 .col-sm-6 .col-md-8
-
.col-xs-6 .col-md-4
+
.col-xs-12 .col-sm-6 .col-md-8
+
.col .col-xs-6 .col-md-4
-
.col-xs-6 .col-sm-4
-
.col-xs-6 .col-sm-4
+
.col .col-xs-6 .col-sm-4
+
.col .col-xs-6 .col-sm-4
-
.col-xs-6 .col-sm-4
+
.col .col-xs-6 .col-sm-4
{% endexample %}
@@ -334,9 +334,9 @@ If more than 12 columns are placed within a single row, each group of extra colu
{% example html %}
-
.col-xs-9
-
.col-xs-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
-
.col-xs-6
Subsequent columns continue along the new line.
+
.col .col-xs-9
+
.col .col-xs-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
+
.col .col-xs-6
Subsequent columns continue along the new line.
{% endexample %}
@@ -348,14 +348,14 @@ With the four tiers of grids available you're bound to run into issues where, at
{% example html %}
-
.col-xs-6 .col-sm-3
-
.col-xs-6 .col-sm-3
+
.col .col-xs-6 .col-sm-3
+
.col .col-xs-6 .col-sm-3
-
.col-xs-6 .col-sm-3
-
.col-xs-6 .col-sm-3
+
.col .col-xs-6 .col-sm-3
+
.col .col-xs-6 .col-sm-3
{% endexample %}
@@ -365,33 +365,33 @@ In addition to column clearing at responsive breakpoints, you may need to **rese
{% example html %}
-
.col-sm-5 .col-md-6
-
.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0
+
.col .col-sm-5 .col-md-6
+
.col .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
-
.col-sm-6 .col-md-5 .col-lg-6
-
.col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0
+
.col.col-sm-6.col-md-5.col-lg-6
+
.col .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
{% endexample %}
### Example: Offsetting columns -Move columns to the right using `.col-md-offset-*` classes. These classes increase the left margin of a column by `*` columns. For example, `.col-md-offset-4` moves `.col-md-4` over four columns. +Move columns to the right using `.offset-md-*` classes. These classes increase the left margin of a column by `*` columns. For example, `.offset-md-4` moves `.col-md-4` over four columns.
{% example html %}
-
.col-md-4
-
.col-md-4 .col-md-offset-4
+
.col-md-4
+
.col-md-4 .offset-md-4
-
.col-md-3 .col-md-offset-3
-
.col-md-3 .col-md-offset-3
+
.col .col-md-3 .offset-md-3
+
.col .col-md-3 .offset-md-3
-
.col-md-6 .col-md-offset-3
+
.col .col-md-6 .offset-md-3
{% endexample %}
@@ -403,14 +403,14 @@ To nest your content with the default grid, add a new `.row` and set of `.col-sm
{% example html %}
-
- Level 1: .col-sm-9 +
+ Level 1: .col .col-sm-9
-
- Level 2: .col-xs-8 .col-sm-6 +
+ Level 2: .col .col-xs-8 .col-sm-6
-
- Level 2: .col-xs-4 .col-sm-6 +
+ Level 2: .col .col-xs-4 .col-sm-6
@@ -425,8 +425,8 @@ Easily change the order of our built-in grid columns with `.col-md-push-*` and `
{% example html %}
-
.col-md-9 .col-md-push-3
-
.col-md-3 .col-md-pull-9
+
.col .col-md-9 .push-md-3
+
.col .col-md-3 .pull-md-9
{% endexample %}
-- cgit v1.2.3 From 414997baa83858b43e9f45af90097f93ed2d6797 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 6 Feb 2016 10:51:59 -0800 Subject: flip things around again, no more base class, try out some new stuff to keep responsive flex grid working --- docs/layout/grid.md | 116 ++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'docs/layout/grid.md') diff --git a/docs/layout/grid.md b/docs/layout/grid.md index 547284635..75ee5d9c3 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -35,13 +35,13 @@ If you're using Bootstrap's compiled CSS, this the example you'll want to start {% example html %}
-
+
One of three columns
-
+
One of three columns
-
+
One of three columns
@@ -268,31 +268,31 @@ Using a single set of `.col-md-*` grid classes, you can create a basic grid syst
{% example html %}
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
-
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
+
md-1
-
md-8
-
md-4
+
md-8
+
md-4
-
md-4
-
md-4
-
md-4
+
md-4
+
md-4
+
md-4
-
md-6
-
md-6
+
md-6
+
md-6
{% endexample %}
@@ -305,21 +305,21 @@ Don't want your columns to simply stack in smaller devices? Use the extra small {% example html %}
-
.col .col-xs-12 .col-md-8
-
.col .col-xs-6 .col-md-4
+
.col-xs-12 .col-md-8
+
.col-xs-6 .col-md-4
-
.col .col-xs-6 .col-md-4
-
.col .col-xs-6 .col-md-4
-
.col .col-xs-6 .col-md-4
+
.col-xs-6 .col-md-4
+
.col-xs-6 .col-md-4
+
.col-xs-6 .col-md-4
-
.col .col-xs-6
-
.col .col-xs-6
+
.col-xs-6
+
.col-xs-6
{% endexample %}
@@ -331,15 +331,15 @@ Build on the previous example by creating even more dynamic and powerful layouts
{% example html %}
-
.col-xs-12 .col-sm-6 .col-md-8
-
.col .col-xs-6 .col-md-4
+
.col-xs-12 .col-sm-6 .col-md-8
+
.col-xs-6 .col-md-4
-
.col .col-xs-6 .col-sm-4
-
.col .col-xs-6 .col-sm-4
+
.col-xs-6 .col-sm-4
+
.col-xs-6 .col-sm-4
-
.col .col-xs-6 .col-sm-4
+
.col-xs-6 .col-sm-4
{% endexample %}
@@ -351,9 +351,9 @@ If more than 12 columns are placed within a single row, each group of extra colu
{% example html %}
-
.col .col-xs-9
-
.col .col-xs-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
-
.col .col-xs-6
Subsequent columns continue along the new line.
+
.col-xs-9
+
.col-xs-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
+
.col-xs-6
Subsequent columns continue along the new line.
{% endexample %}
@@ -365,14 +365,14 @@ With the four tiers of grids available you're bound to run into issues where, at
{% example html %}
-
.col .col-xs-6 .col-sm-3
-
.col .col-xs-6 .col-sm-3
+
.col-xs-6 .col-sm-3
+
.col-xs-6 .col-sm-3
-
.col .col-xs-6 .col-sm-3
-
.col .col-xs-6 .col-sm-3
+
.col-xs-6 .col-sm-3
+
.col-xs-6 .col-sm-3
{% endexample %}
@@ -382,13 +382,13 @@ In addition to column clearing at responsive breakpoints, you may need to **rese
{% example html %}
-
.col .col-sm-5 .col-md-6
-
.col .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
+
.col-sm-5 .col-md-6
+
.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
-
.col.col-sm-6.col-md-5.col-lg-6
-
.col .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
+
.col.col-sm-6.col-md-5.col-lg-6
+
.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
{% endexample %}
@@ -400,15 +400,15 @@ Move columns to the right using `.offset-md-*` classes. These classes increase t
{% example html %}
-
.col-md-4
-
.col-md-4 .offset-md-4
+
.col-md-4
+
.col-md-4 .offset-md-4
-
.col .col-md-3 .offset-md-3
-
.col .col-md-3 .offset-md-3
+
.col-md-3 .offset-md-3
+
.col-md-3 .offset-md-3
-
.col .col-md-6 .offset-md-3
+
.col-md-6 .offset-md-3
{% endexample %}
@@ -420,14 +420,14 @@ To nest your content with the default grid, add a new `.row` and set of `.col-sm
{% example html %}
-
- Level 1: .col .col-sm-9 +
+ Level 1: .col-sm-9
-
- Level 2: .col .col-xs-8 .col-sm-6 +
+ Level 2: .col-xs-8 .col-sm-6
-
- Level 2: .col .col-xs-4 .col-sm-6 +
+ Level 2: .col-xs-4 .col-sm-6
@@ -442,8 +442,8 @@ Easily change the order of our built-in grid columns with `.col-md-push-*` and `
{% example html %}
-
.col .col-md-9 .push-md-3
-
.col .col-md-3 .pull-md-9
+
.col-md-9 .push-md-3
+
.col-md-3 .pull-md-9
{% endexample %}
-- cgit v1.2.3 From 7114e94d6668ad2b7b91b67d2b3d75a9258b1c2a Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 6 Feb 2016 13:02:10 -0800 Subject: formatting --- docs/layout/grid.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'docs/layout/grid.md') diff --git a/docs/layout/grid.md b/docs/layout/grid.md index 75ee5d9c3..b0e00a396 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -52,8 +52,7 @@ The above example creates three equal-width columns on small, medium, large, and ## Grid options -While Bootstrap uses `em`s or `rem`s for defining most sizes, `px`s are used for grid breakpoints and container widths. -This is because the viewport width is in pixels and does not change with the [font size](https://drafts.csswg.org/mediaqueries-3/#units). +While Bootstrap uses `em`s or `rem`s for defining most sizes, `px`s are used for grid breakpoints and container widths. This is because the viewport width is in pixels and does not change with the [font size](https://drafts.csswg.org/mediaqueries-3/#units). See how aspects of the Bootstrap grid system work across multiple devices with a handy table. -- cgit v1.2.3 From bc45addbc37e70e195c28cc6857360202d5e565e Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 6 Feb 2016 13:02:28 -0800 Subject: update grid vars docs --- docs/layout/grid.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'docs/layout/grid.md') diff --git a/docs/layout/grid.md b/docs/layout/grid.md index b0e00a396..d43f6e8ab 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -135,9 +135,12 @@ When using Bootstrap's source Sass files, you have the option of using Sass vari ### Variables -Variables determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below. +Variables and maps determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below. {% highlight scss %} +$grid-columns: 12; +$grid-gutter-width: 15px; + $grid-breakpoints: ( // Extra small screen / phone xs: 0, @@ -151,9 +154,12 @@ $grid-breakpoints: ( xl: 1200px ); - -$grid-columns: 12; -$grid-gutter-width: 1.875rem; +$container-max-widths: ( + sm: 576px, + md: 720px, + lg: 940px, + xl: 1140px +) !default; {% endhighlight %} ### Mixins -- cgit v1.2.3 From fb4f5f0bf1e22f707bdd16880fe19328df091bde Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 6 Feb 2016 13:02:42 -0800 Subject: document how to customize grid tiers --- docs/layout/grid.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'docs/layout/grid.md') diff --git a/docs/layout/grid.md b/docs/layout/grid.md index d43f6e8ab..3a76a651b 100644 --- a/docs/layout/grid.md +++ b/docs/layout/grid.md @@ -452,3 +452,25 @@ Easily change the order of our built-in grid columns with `.col-md-push-*` and `
{% endexample %}
+ +## Customizing the grid + +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: + +{% highlight scss %} +$grid-breakpoints: ( + sm: 480px, + md: 768px, + lg: 1024px +); + +$container-max-widths: ( + sm: 420px, + md: 720px, + lg: 940px +) !default; +{% 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. -- cgit v1.2.3