jQuery.css(): Firefox don't return 'auto' values

前端 未结 4 1077
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-17 19:43

I\'m setting top or bottom and left or right values to a few elements. When i\'m trying to access this values with Firefox (16.0.2), i get a wrong value for top

4条回答
  •  萌比男神i
    2020-12-17 20:20

    This is down to the browser and how it interprets the styles, it is somewhat out of your control. However, with particular CSS and jQuery workarounds you should be able to get around it. For instance, if you do not need to the item to be positioned absolutely then you could remove this, or change it to position:static;

    Have a look at this question.

    As to why Chrome and IE return different values: .css() provides a unified gateway to the browsers' computed style functions, but it doesn't unify the way the browsers actually compute the style. It's not uncommon for browsers to decide such edge cases differently.

提交回复
热议问题