views:

23

answers:

2

Hi, I have an absolutely positioned [element] such that in the CSS, I've explicitly set its left property to -9999px. I have not set the top property. I cannot set it, since I want the element to "stay" where it is in the DOM (even though it's out of the document flow)

When I call [element].css('top') in jQuery, FF returns a value. IE and Safari return 'auto'. Is there a way to get the top value in IE/Safari? The CSS top value seems to be different than the top value coming from .offset().

+2  A: 
jQuery('.elm').offset().top
Praveen Prasad
Ah, so that's the correct way to get the correct top value. Thank you.
Stephen
A: 

auto is a valid setting for the top: setting, so no, that's what it actually is. I'll also throw in that Chrome shows auto as well. You'll have to use .offset().top.

It's also worth noting that I'm getting 10 for both .css('top') and .offset().top in Firefox using http://jsfiddle.net/HVxtd/

http://www.w3.org/TR/CSS2/visuren.html#position-props

Robert