jQuery offset() not working in some browsers, on some computers

元气小坏坏 提交于 2019-12-01 10:52:47

I finally figured out what was happening. I had a css rule defining the width of the body:

body {
    width: 900px;
}

Once I changed this to width: 100%; and enclosed the entire page in a div of width 900px, it worked as expected.

It looks like IE uses the body element to measure top and left values for offset(), but uses the window edge when to measure top and left distances when positioning an item absolutely.

I hope this answer will save someone else all the time I've wasted on this...

Maple

I met a similar question,finally discovered the float property affects relative,making the relative div not stable in Internet Explorer 8 but performs well in firefox.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!