Bug 178261 - CSS min-width and max-width media features should not round fractional pixel values
Summary: CSS min-width and max-width media features should not round fractional pixel ...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-10-13 07:40 PDT by Šime Vidas
Modified: 2022-11-25 20:26 PST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Šime Vidas 2017-10-13 07:40:20 PDT
These two media queries both evaluate to `true` in the latest Safari on an iPhone 6:

@media (max-width: 374.99px) {
  p::before {
    content: "👍";
  }
}

@media (min-width: 375px) {
  p::after {
    content: "👍";
  }
}

Live demo: https://output.jsbin.com/tafogug/quiet

This doesn’t make sense. The viewport width cannot at the same time be ≤ 374.99px and ≥ 375px. WebKit seems to round the fractional pixel value. Why?

Note that this behavior is preventing the postcss-media-minmax plugin from properly polyfilling “range mode” media queries. See: https://github.com/postcss/postcss-media-minmax/issues/19.
Comment 1 Radar WebKit Bug Importer 2017-10-13 16:03:24 PDT
<rdar://problem/34988263>
Comment 2 Patrick H. Lauke 2017-10-14 07:19:16 PDT
note this may start having impact on bootstrap-based sites when we merge this https://github.com/twbs/bootstrap/pull/24299
Comment 3 Patrick H. Lauke 2018-01-02 03:44:30 PST
Note that Bootstrap 4 now uses fractional viewport values, and yes first reports of incompatibilities are coming in...

https://github.com/twbs/bootstrap/issues/25166

And note the CSS Media Queries 4 spec includes the fractional viewport advice https://github.com/w3c/csswg-drafts/pull/1083
Comment 4 yisibl 2022-07-14 22:06:26 PDT
I can no longer reproduce this bug in Safari 15.4 (17613.1.17.1.6), it looks like it's fixed?
Comment 5 Šime Vidas 2022-07-14 23:34:49 PDT
I also can no longer reproduce. I tested on iPhone 8 with iOS 15.5. Only the (min-width: 375px) media query matches now.