Skip to content

Commit 0240136

Browse files
committed
Merge pull request #17403 from twbs/use-px-for-window-sizes
Change grid and container sizes to px
2 parents a9a2912 + eabed0e commit 0240136

File tree

4 files changed

+56
-47
lines changed

4 files changed

+56
-47
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 class="text-center">
6366
Extra small<br>
64-
<small>&lt;34em / 480px</small>
67+
<small>&lt;544px</small>
6568
</th>
6669
<th class="text-center">
6770
Small<br>
68-
<small>&ge;34em / 480px</small>
71+
<small>&ge;544px</small>
6972
</th>
7073
<th class="text-center">
7174
Medium<br>
72-
<small>&ge;45em / 720px</small>
75+
<small>&ge;768px</small>
7376
</th>
7477
<th class="text-center">
7578
Large<br>
76-
<small>&ge;62em / 992px</small>
79+
<small>&ge;992px</small>
7780
</th>
7881
<th class="text-center">
7982
Extra large<br>
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>576px</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: 544px,
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
@@ -90,13 +90,13 @@ $grid-breakpoints: (
9090
// Extra small screen / phone
9191
xs: 0,
9292
// Small screen / phone
93-
sm: 34em,
93+
sm: 544px,
9494
// Medium screen / tablet
95-
md: 48em,
95+
md: 768px,
9696
// Large screen / desktop
97-
lg: 62em,
97+
lg: 992px,
9898
// Extra large screen / wide desktop
99-
xl: 75em
99+
xl: 1200px
100100
) !default;
101101

102102

@@ -105,10 +105,10 @@ $grid-breakpoints: (
105105
// Define the maximum width of `.container` for different screen sizes.
106106

107107
$container-max-widths: (
108-
sm: 34rem, // 480
109-
md: 45rem, // 720
110-
lg: 60rem, // 960
111-
xl: 72.25rem // 1140
108+
sm: 576px,
109+
md: 720px,
110+
lg: 940px,
111+
xl: 1140px
112112
) !default;
113113

114114

scss/bootstrap-grid.scss

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,46 @@
88
// Variables
99
//
1010

11-
// Grid system
11+
12+
// Grid breakpoints
1213
//
13-
// Define your custom responsive grid.
14+
// Define the minimum and maximum dimensions at which your layout will change,
15+
// adapting to different screen sizes, for use in media queries.
16+
1417
$grid-breakpoints: (
1518
// Extra small screen / phone
1619
xs: 0,
1720
// Small screen / phone
18-
sm: 34em,
21+
sm: 544px,
1922
// Medium screen / tablet
20-
md: 48em,
23+
md: 768px,
2124
// Large screen / desktop
22-
lg: 62em,
25+
lg: 992px,
2326
// Extra large screen / wide desktop
24-
xl: 75em
27+
xl: 1200px
2528
) !default;
2629

27-
// Number of columns in the grid.
28-
$grid-columns: 12 !default;
29-
30-
// Padding between columns. Gets divided in half for the left and right.
31-
$grid-gutter-width: 1.5rem !default;
32-
3330

34-
// Container sizes
31+
// Grid containers
3532
//
3633
// Define the maximum width of `.container` for different screen sizes.
3734

3835
$container-max-widths: (
39-
sm: 34rem, // 480
40-
md: 45rem, // 720
41-
lg: 60rem, // 960
42-
xl: 72.25rem // 1140
36+
sm: 576px,
37+
md: 720px,
38+
lg: 940px,
39+
xl: 1140px
4340
) !default;
4441

4542

43+
// Grid columns
44+
//
45+
// Set the number of columns and specify the width of the gutters.
46+
47+
$grid-columns: 12 !default;
48+
$grid-gutter-width: 1.875rem !default; // 30px
49+
50+
4651
//
4752
// Grid mixins
4853
//

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: 544px, 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: 544px, 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: 544px, md: 768px))
25+
// 544px
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: 544px, 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)