1

When an element is position:absolute and right:[whatever], trying to get $("#div").css("left") returns the rendered left value, and not auto like I'd expect. I've set up a test here: http://jsbin.com/ayesat/1/ In Chrome it alerts "auto", but Firefox alerts a px value.

Any way to force Firefox to return whatever is set in the css style?

peirix
  • 36,512
  • 23
  • 96
  • 126
  • Check out [this answer](http://stackoverflow.com/a/5830517/133802) for retreiving the actual CSS styles of an element. – David Hedlund Apr 22 '13 at 12:38
  • @DavidHedlund But that seems to give me all the styles? Which is a bit too much. I just want whatever is set as value for `left` in the stylesheet. – peirix Apr 22 '13 at 12:46

1 Answers1

1

You can get what you want if the element is also styled as display:none: that will always return computed styles.

Otherwise, getComputedStyle returns something ... complicated. See http://dev.w3.org/csswg/cssom/#resolved-value

Boris Zbarsky
  • 34,758
  • 5
  • 52
  • 55