Side navigation
#9880 closed bug (worksforme)
Opened July 21, 2011 04:31AM UTC
Closed July 25, 2011 11:00AM UTC
Last modified March 16, 2012 01:59AM UTC
.css('background-position') returns inaccurate values in Chrome
Reported by: | ullagone@gmail.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | css | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This only is a problem for me in Chromium (version: 12.0.742.112 (90304) Ubuntu 11.04), things work fine in Firefox.
If I have this html:
<div id="test" style="background-position: 100px 100px;"></div>
The function:
function backgroundPosition () { return $('#test').css('background-position'); }
returns "120px 120px".
All pixel values seem like they're being multiplied by 120%, so any value greater than 4 is inaccurate (i.e. 5px will return 6px).
There's no problem with percentage values. The problem is the same even if I try to access background-position-x and background-position-y individually, pixel values are multiplied by 120%.
Here's a workaround I'm using that returns the correct value:
function backgroundPosition () { var container = $("<div></div>"); container.append($('#test').clone()); return $(container.html()).css('background-position'); }
Attachments (0)
Change History (4)
Changed July 25, 2011 11:00AM UTC by comment:1
component: | unfiled → css |
---|---|
priority: | undecided → low |
resolution: | → worksforme |
status: | new → closed |
Changed August 30, 2011 10:13PM UTC by comment:2
Hey there,
I just ran into this issue, the background position is being multiplied by the level of zoom on the browser..
Changed January 06, 2012 05:16PM UTC by comment:3
I am able to reproduce this using the following JSFiddle:
It prints 83px 83px instead of 100px 100px. Using the plain DOM API produces the correct value.
This is reproducible in Google Chrome version 16.0.912.63 on Mac OS 10.6 with a Zoom level set to one below the default (in other words, if you hit Zoom Out once).
Changed March 16, 2012 01:59AM UTC by comment:4
I have found this problem too. Is there any temporary fix available?
Thanks for submitting a ticket!. I've put together a test case based on the information you've provided here: http://jsfiddle.net/addyosmani/WH7dz/. Using jQuery (edge/git) ie. 1.6.2+ in Chromium 12.07, there is no different between the expected output in Firefox 5, Chrome and Chromium (ie. 100px). As such we'll be closing this ticket as worksforme, however if you are able to provide further information that another member of the team can verify as being an issue with core, we'll be happy to re-investigate.