Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
css() reports wrong width/height in Chrome on certain zoom levels #3808
Comments
|
Ugh, confirmed on the git build. I think we need something like a unit-preserving round comparison. Fortunately, this is reproducible with |
gibson042
added
CSS
Dimensions
and removed
CSS
labels
Oct 4, 2017
simonemazzoni
commented
Oct 11, 2017
|
Same here, @gibson042 any news about it? |
|
A PR would be welcome, but if nobody expresses interest then I'll probably put in a fix before the next release |
|
@gibson042 I would like to work on this issue. |
|
@SaptakS Feel free! |
pushed a commit
to eclipse/scout.rt
that referenced
this issue
Nov 24, 2017
pushed a commit
to eclipse/scout.rt
that referenced
this issue
Nov 24, 2017
SaptakS
referenced this issue
Dec 4, 2017
Merged
Fix the width calculation of border-box due to browser zoom #3872
gibson042
closed this
in
f00a075
Dec 6, 2017
gibson042
added this to the 3.3.0 milestone
Dec 6, 2017
cuzzins
commented
Dec 6, 2017
|
Just to add to this, I reported this (or a very similar issue back in May) and was essentially told that browser zoom is not supported and I should essentially expect things to break around it between versions. Has the policy changed? In the end I had to rip the code out that was using jQuery and rewrite it, and also have not been able to rely on jQuery height/width for other parts as it may break with no intention of fixing it. See #3681 for what I originally described as the issue |
|
You didn't do anything wrong, but this particular issue was phrased in such a way and came with sufficient detail that it merited more attention. Even though both probably stemmed from similar underlying causes, this one highlighted a fundamental problem of our support tests failing with non-default zoom levels, which is more severe than any given response being wrong. And as @dmethvin noted, landing #3738 and #3656 changed things. We still can't guarantee behavior with non-default zoom, but as of f00a075 we have confidence that our browser behavior observations are correct (which is likely to resolve issues like #3681). Our official policy remains "dimensions may be incorrect when the page is zoomed by the user", but we do try to make things work even outside of normal operating parameters if a fix can be achieved without incurring undue cost (factoring in all dimensions—file size, performance, code complexity, testability, maintenance burden, followup reports, etc.). I feel bad that you had to remove jQuery dimensions calls for your application, and hope that you will consider restoring them after 3.3 is released this month. And please do report issues you encounter in the future. Our notices are caveats, not absolutes. |
GulajavaMinistudio
referenced this issue
in GulajavaMinistudio/jquery
Dec 7, 2017
Merged
Update upstream #31
bschwarzent
commented
Dec 12, 2017
|
@gibson042 Is there a way for me to verify the fix? I tried https://code.jquery.com/jquery-git.js, but that file does not seem to include the fix (yet?). |
|
Yes, that's correct. But it looks like the file is stuck: |
|
@gibson042 that's what our Jenkins looks like now most of the time: |
bschwarzent
commented
Dec 13, 2017
|
Thanks! I was able to successfully verify the fix with the updated jquery-git.js version. |

bschwarzent commentedOct 4, 2017
jQuery 3.2.1 reports wrong sizes for elements with
box-sizing: border-boxin Chrome (v61) on certain browser zoom levels. It seems to add the element's insets (padding + border) to its width and height, although the CSS width already includes the insets.Demonstration
http://output.jsbin.com/yipudeloya/
In the provided test case, we have two <div>s with 10px padding on all sides, 1px border on all sides and a CSS width/height set to 32px. Because box-sizing is set to
border-box, the visual size of the elements is 32x32px with a remaining "inner" space of 10px. At 100% browser zoom level, this is correctly reported both bycss('width')and.outerWidth().If we now zoom to 110%, the numbers get slightly changed, probably due to some rounding errors (31.9886px instead of 32px). Because we should always get "CSS pixels" that are not affected by browser zoom, I would have expected those numbers to stay the same - but I can live with that. The real problem occurs when you reload the page while having the browser zoom at 110%! Now the width is completely incorrect (53.977236000000005px instead of 32px).
If the page uses those values for programmatic layout, the results will be wrong. You can see the effect in the demo. The CSS width and height of the first <div> are copied to the second, so they should always be the same size. However, if you start at 100%, the second <div> is much larger.
Analysis
Analysis has shown that this seems to be caused by the internal function
computeStyleTests()in css/support.js that wrongly sets the internal propertyboxSizingReliableValtofalse. Apparently, this happens because of a rounding error. In my case, the test div's measured width is 3.997px, which is not equal to the expected value of 4px. What's worse, this internal property is only calculated once! So when you start at 110% zoom, and then reset it to 100%, the problem still persists until you completely reload the page.I could observe the problem at the following zoom levels: 110%, 90%, 80%, 67% and 33%.
Firefox (v56) and IE (v11) don't seem to be affected by this problem. Also, with jQuery 2.1.4, everything works fine on all browsers. All tests were performed on Windows 7 with default DPI and font size settings.