Skip to content

Commit a6fce9c

Browse files
committed
Change grid and container sizes to px
Changes grid and container sizes to `px`, as the viewport pixel size does not depend on the font size. The actual em values were inconsistent with the docs, while the docs were also inconsistent with the comments, namely: * `sm` breakpoint was 34em which is 558px, not 480px. Changed to 480px, matching the docs and Bootstrap 3. * `lg` max width was 60rem which is 960px, less gutter than `md`. Changed to 940px, same as Bootstrap 3. * `xl` max width was 72.25rem which is 1140px not 1156px. Changed to 1140px matching the comment but not the docs. All the values are now the same as they were in Bootstrap 3. Addresses #17070 and #17388.
1 parent 88ec75b commit a6fce9c

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
lines changed

docs/layout/grid.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ The above example creates three equal-width columns on small, medium, large, and
5252

5353
## Grid options
5454

55+
While Bootstrap uses `em`s or `rem`s for defining most sizes, `px`s are used for grid breakpoints and container widths.
56+
This is because the viewport width is in pixels and does not change with the [font size](https://drafts.csswg.org/mediaqueries-3/#units).
57+
5558
See how aspects of the Bootstrap grid system work across multiple devices with a handy table.
5659

5760
<div class="table-responsive">
@@ -61,23 +64,23 @@ See how aspects of the Bootstrap grid system work across multiple devices with a
6164
<th></th>
6265
<th>
6366
Extra small
64-
<small>&lt;34em / 480px</small>
67+
<small>&lt;480px</small>
6568
</th>
6669
<th>
6770
Small
68-
<small>&ge;34em / 480px</small>
71+
<small>&ge;480px</small>
6972
</th>
7073
<th>
7174
Medium
72-
<small>&ge;45em / 720px</small>
75+
<small>&ge;768px</small>
7376
</th>
7477
<th>
7578
Large
76-
<small>&ge;62em / 992px</small>
79+
<small>&ge;992px</small>
7780
</th>
7881
<th>
7982
Extra large
80-
<small>&ge;75em / 1200px</small>
83+
<small>&ge;1200px</small>
8184
</th>
8285
</tr>
8386
</thead>
@@ -90,10 +93,10 @@ See how aspects of the Bootstrap grid system work across multiple devices with a
9093
<tr>
9194
<th class="text-nowrap" scope="row">Container width</th>
9295
<td>None (auto)</td>
93-
<td>34rem / 480px</td>
94-
<td>45rem / 720px</td>
95-
<td>60rem / 960px</td>
96-
<td>72.25rem / 1156px</td>
96+
<td>480px</td>
97+
<td>720px</td>
98+
<td>940px</td>
99+
<td>1140px</td>
97100
</tr>
98101
<tr>
99102
<th class="text-nowrap" scope="row">Class prefix</th>
@@ -109,7 +112,7 @@ See how aspects of the Bootstrap grid system work across multiple devices with a
109112
</tr>
110113
<tr>
111114
<th class="text-nowrap" scope="row">Gutter width</th>
112-
<td colspan="5">30px (15px on each side of a column)</td>
115+
<td colspan="5">1.875rem / 30px (15px on each side of a column)</td>
113116
</tr>
114117
<tr>
115118
<th class="text-nowrap" scope="row">Nestable</th>
@@ -140,17 +143,18 @@ $grid-breakpoints: (
140143
// Extra small screen / phone
141144
xs: 0,
142145
// Small screen / phone
143-
sm: 34em, // 480px
146+
sm: 480px,
144147
// Medium screen / tablet
145-
md: 48em, // 768px
148+
md: 768px,
146149
// Large screen / desktop
147-
lg: 62em, // 992px
150+
lg: 992px,
148151
// Extra large screen / wide desktop
149-
xl: 75em // 1200px
152+
xl: 1200px
150153
) !default;
151154

155+
152156
$grid-columns: 12;
153-
$grid-gutter-width: 1.5rem;
157+
$grid-gutter-width: 1.875rem;
154158
{% endhighlight %}
155159

156160
### Mixins

scss/_variables.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ $grid-breakpoints: (
8888
// Extra small screen / phone
8989
xs: 0,
9090
// Small screen / phone
91-
sm: 34em,
91+
sm: 480px,
9292
// Medium screen / tablet
93-
md: 48em,
93+
md: 768px,
9494
// Large screen / desktop
95-
lg: 62em,
95+
lg: 992px,
9696
// Extra large screen / wide desktop
97-
xl: 75em
97+
xl: 1200px
9898
) !default;
9999

100100

@@ -103,10 +103,10 @@ $grid-breakpoints: (
103103
// Define the maximum width of `.container` for different screen sizes.
104104

105105
$container-max-widths: (
106-
sm: 34rem, // 480
107-
md: 45rem, // 720
108-
lg: 60rem, // 960
109-
xl: 72.25rem // 1140
106+
sm: 480px,
107+
md: 720px,
108+
lg: 940px,
109+
xl: 1140px
110110
) !default;
111111

112112

scss/mixins/_breakpoints.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
//
33
// Breakpoints are defined as a map of (name: minimum width), order from small to large:
44
//
5-
// (xs: 0, sm: 34rem, md: 45rem)
5+
// (xs: 0, sm: 480px, md: 768px)
66
//
77
// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default.
88

99
// Name of the next breakpoint, or null for the last breakpoint.
1010
//
1111
// >> breakpoint-next(sm)
1212
// md
13-
// >> breakpoint-next(sm, $breakpoints: (xs: 0, sm: 34rem, md: 45rem))
13+
// >> breakpoint-next(sm, (xs: 0, sm: 480px, md: 768px))
1414
// md
1515
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md))
1616
// md
@@ -21,8 +21,8 @@
2121

2222
// Minimum breakpoint width. Null for the smallest (first) breakpoint.
2323
//
24-
// >> breakpoint-min(sm, (xs: 0, sm: 34rem, md: 45rem))
25-
// 34rem
24+
// >> breakpoint-min(sm, (xs: 0, sm: 480px, md: 768px))
25+
// 480px
2626
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
2727
$min: map-get($breakpoints, $name);
2828
@return if($min != 0, $min, null);
@@ -31,11 +31,11 @@
3131
// Maximum breakpoint width. Null for the largest (last) breakpoint.
3232
// The maximum value is calculated as the minimum of the next one less 0.1.
3333
//
34-
// >> breakpoint-max(sm, (xs: 0, sm: 34rem, md: 45rem))
35-
// 44.9rem
34+
// >> breakpoint-max(sm, (xs: 0, sm: 480px, md: 768px))
35+
// 767px
3636
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
3737
$next: breakpoint-next($name, $breakpoints);
38-
@return if($next, breakpoint-min($next, $breakpoints) - 0.1, null);
38+
@return if($next, breakpoint-min($next, $breakpoints) - 1px, null);
3939
}
4040

4141
// Media of at least the minimum breakpoint width. No query for the smallest breakpoint.

0 commit comments

Comments
 (0)