Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#12502 closed bug (cantfix)

Bug in .css() regarding positioning with non-pixel values

Reported by: wyverns.spirit@… Owned by:
Priority: low Milestone: None
Component: css Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

If you have an absolutely positioned element using anything but a pixel value for its position, trying to access the value with .css() will transform it to a pixel value. A barebones example: http://jsfiddle.net/DqXyK/

This happens in every browser except for webkit. We recently updated our jquery from version 1.4.2 to 1.8.0, which marks the regression point for us. The first comment on http://api.jquery.com/css/ describes the same bug in version 1.4.4. We couldn't find a bug report in the tracker, so I opened a new one. Thanks in advance for checking it out!

Change History (3)

comment:1 Changed 6 years ago by mikesherov

Component: unfiledcss
Priority: undecidedlow
Resolution: cantfix
Status: newclosed

We're not going to fix these differences at this point, mainly because we can't. I've advocated fo consistency at the browser vendor and standards body level, and they're working on it.

If you'd like the position in pixels, please use the jQuery .position() and .offset() methods.

comment:2 in reply to:  1 Changed 6 years ago by anonymous

Replying to mikesherov:

We're not going to fix these differences at this point, mainly because we can't. I've advocated fo consistency at the browser vendor and standards body level, and they're working on it.

If you'd like the position in pixels, please use the jQuery .position() and .offset() methods.

Fair enough. To anyone else stumbling across this: We've worked around it by using the native $test[0].style.left instead of $test.css('left') to get the percentage value in all browsers.

comment:3 Changed 6 years ago by mikesherov

also, .style.left only works for styles applied directly to an element.

Note: See TracTickets for help on using tickets.