postcss-media-minmax icon indicating copy to clipboard operation
postcss-media-minmax copied to clipboard

Change integer pixels by .02px rather than 1px

Open andersk opened this issue 4 years ago • 5 comments

According to the Bootstrap developers, using .02px rather than .01px should be sufficient to work around the Safari rounding bug.

Fixes #19.

andersk avatar Feb 04 '21 02:02 andersk

Has this been tested in Safari? 1px will have bugs?

yisibl avatar Feb 04 '21 05:02 yisibl

I don’t have a Mac myself, but twbs/bootstrap#25177 has been tested extensively in Safari, having been part of Bootstrap for the last three years.

I’m not sure how to interpret “1px will have bugs?”, but if the question is whether this solves a real problem with the existing 1px offset, the answer is yes. On high-DPI screens or at non-default zoom levels, Firefox and Chrome do in practice evaluate media queries at fractional px sizes, so that it’s possible for neither @media (width <= 599px) nor @media (width >= 600px) to match. I have observed this. See also

https://stackoverflow.com/questions/51566916/why-does-bootstrap-use-a-0-02px-difference-between-screen-size-thresholds-in-its https://github.com/w3c/csswg-drafts/pull/1083 https://bugzilla.mozilla.org/show_bug.cgi?id=1120090 https://bugs.chromium.org/p/chromium/issues/detail?id=689096

andersk avatar Feb 04 '21 05:02 andersk

I'm sorry to reply to you so late. I ran git rebase origin/master on this branch to make sure there are no extra messages on the commit.

I think the change to 0.02 is better, it fixes some browser bugs that I was able to reproduce in Chrome 103 on my MacBook Pro.

I'll need to do some further research on the JS logic changes, and may be able to merge them after some tweaking.

yisibl avatar Jul 15 '22 04:07 yisibl

Thanks. It looks like you rewrote all the Git history to change your email address—FYI in the future, better practice for that is to add a mailmap.

I removed the empty commit left on this PR by your rebase.

andersk avatar Jul 15 '22 05:07 andersk

Okay

yisibl avatar Jul 15 '22 05:07 yisibl