Skip to content

Commit 7044ea8

Browse files
patrickhlaukeXhmikosR
authored andcommitted
Patch fractional viewport widths to work around Safari rounding bug (#25177)
Includes simplifying the prose in `tables.md` and adding the bug to the list of browser bugs. Closes #25166
1 parent 1cfbb83 commit 7044ea8

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

_data/browser-bugs.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,16 @@
278278
origin: >
279279
Bootstrap#20732
280280
281+
-
282+
browser: >
283+
Safari
284+
summary: >
285+
CSS `min-width` and `max-width` media features should not round fractional pixel
286+
upstream_bug: >
287+
WebKit#178261
288+
origin: >
289+
Bootstrap#25166
290+
281291
-
282292
browser: >
283293
Safari (OS X)

docs/4.0/content/tables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ Regular table background variants are not available with the dark table, however
553553
{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %}
554554
{{ callout-include | markdownify }}
555555

556-
Create responsive tables by wrapping any `.table` with `.table-responsive{-sm|-md|-lg|-xl}`, making the table scroll horizontally at each `max-width` breakpoint of 575.99px, 767.99px, 991.99px, and 1119.99px, respectively.
556+
Create responsive tables by wrapping any `.table` with `.table-responsive{-sm|-md|-lg|-xl}`, making the table scroll horizontally at each `max-width` breakpoint of up to (but not including) 576px, 768px, 992px, and 1120px, respectively.
557557

558558
{% capture callout-include %}{% include callout-info-mediaqueries-breakpoints.md %}{% endcapture %}
559559
{{ callout-include | markdownify }}

docs/4.0/examples/offcanvas/offcanvas.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ footer {
1717
* Off Canvas
1818
* --------------------------------------------------
1919
*/
20-
@media screen and (max-width: 767.99px) {
20+
@media screen and (max-width: 767.98px) {
2121
.row-offcanvas {
2222
position: relative;
2323
transition: all .25s ease-out;

docs/4.0/layout/overview.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ We occasionally use media queries that go in the other direction (the given scre
8888

8989
{% highlight scss %}
9090
// Extra small devices (portrait phones, less than 576px)
91-
@media (max-width: 575.99px) { ... }
91+
@media (max-width: 575.98px) { ... }
9292

9393
// Small devices (landscape phones, less than 768px)
94-
@media (max-width: 767.99px) { ... }
94+
@media (max-width: 767.98px) { ... }
9595

9696
// Medium devices (tablets, less than 992px)
97-
@media (max-width: 991.99px) { ... }
97+
@media (max-width: 991.98px) { ... }
9898

9999
// Large devices (desktops, less than 1200px)
100-
@media (max-width: 1199.99px) { ... }
100+
@media (max-width: 1199.98px) { ... }
101101

102102
// Extra large devices (large desktops)
103103
// No media query since the extra-large breakpoint has no upper bound on its width
@@ -119,16 +119,16 @@ There are also media queries and mixins for targeting a single segment of screen
119119

120120
{% highlight scss %}
121121
// Extra small devices (portrait phones, less than 576px)
122-
@media (max-width: 575.99px) { ... }
122+
@media (max-width: 575.98px) { ... }
123123

124124
// Small devices (landscape phones, 576px and up)
125-
@media (min-width: 576px) and (max-width: 767.99px) { ... }
125+
@media (min-width: 576px) and (max-width: 767.98px) { ... }
126126

127127
// Medium devices (tablets, 768px and up)
128-
@media (min-width: 768px) and (max-width: 991.99px) { ... }
128+
@media (min-width: 768px) and (max-width: 991.98px) { ... }
129129

130130
// Large devices (desktops, 992px and up)
131-
@media (min-width: 992px) and (max-width: 1199.99px) { ... }
131+
@media (min-width: 992px) and (max-width: 1199.98px) { ... }
132132

133133
// Extra large devices (large desktops, 1200px and up)
134134
@media (min-width: 1200px) { ... }
@@ -149,7 +149,7 @@ Similarly, media queries may span multiple breakpoint widths:
149149
{% highlight scss %}
150150
// Example
151151
// Apply styles starting from medium devices and up to extra large devices
152-
@media (min-width: 768px) and (max-width: 1199.99px) { ... }
152+
@media (min-width: 768px) and (max-width: 1199.98px) { ... }
153153
{% endhighlight %}
154154

155155
The Sass mixin for targeting the same screen size range would be:

scss/mixins/_breakpoints.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@
2929
}
3030

3131
// Maximum breakpoint width. Null for the largest (last) breakpoint.
32-
// The maximum value is calculated as the minimum of the next one less 0.01px
32+
// The maximum value is calculated as the minimum of the next one less 0.02px
3333
// to work around the limitations of `min-` and `max-` prefixes and viewports with fractional widths.
3434
// See https://www.w3.org/TR/mediaqueries-4/#mq-min-max
35+
// Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari.
36+
// See https://bugs.webkit.org/show_bug.cgi?id=178261
3537
//
3638
// >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
37-
// 767px
39+
// 767.98px
3840
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
3941
$next: breakpoint-next($name, $breakpoints);
40-
@return if($next, breakpoint-min($next, $breakpoints) - .01px, null);
42+
@return if($next, breakpoint-min($next, $breakpoints) - .02px, null);
4143
}
4244

4345
// Returns a blank string if smallest breakpoint, otherwise returns the name with a dash infront.

0 commit comments

Comments
 (0)