Absolute position element reports different offsetWidth values based on left value
Reported by
kwea...@tpctraining.com,
Oct 20 2017
|
||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce the problem: 1. View the fiddle: https://fiddle.jshell.net/n93pz3ve/4/ 2. Click the two buttons to adjust the div's left value between 100px and 100.5px 3. Notice that the offsetWidth of the div will change from 115 to 114. What is the expected behavior? An element with a width and height of an exact em value should always report the same offsetWidth value, regardless of positioning. What went wrong? This seems to occur in some situations where the following conditions exist: 1. Element has a non-integer font-size (has decimal value) 2. Element has an em width. 3. Element is position:absolute and switches between an integer and non-integer left value. On a strange side note, the issue was not occurring when using position:relative. Have not done extensive testing on that, though. Did this work before? Yes 20 Does this work in other browsers? Yes Chrome version: 61.0.3163.100 Channel: stable OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version: Shockwave Flash 27.0 r0 This also occurred in Safari version 6.2 to 8. Every other version and every other browser I tested could not replicate the issue. Is it even worth mentioning the regression when it was over 40 versions ago?
,
Oct 30 2017
This is by design, offsetWidth (and height) return pixel-grid aligned values which are dependent on the left (and top) position. See https://trac.webkit.org/wiki/LayoutUnit for details. For the full precision, position agnostic size use getBoundingClientRect().width instead.
,
Oct 30 2017
#2 - but if Chrome is the only browser that behaves this way now, perhaps it is worth a reconsideration? |
||
►
Sign in to add a comment |
||
Comment 1 by krajshree@chromium.org
, Oct 23 2017Labels: -Type-Bug-Regression M-64 Needs-Milestone OS-Linux OS-Mac Type-Bug
Status: Untriaged (was: Unconfirmed)