开发者

jQuery position() / scrollTop() inaccuracy

I have a bunch of divs in a larger div that scrolls.

I want to scroll programmatically to a 'selected' inner div. So I get position().top of the inner div and set this value using scrollTop() on the outer div.

Great, it works, almost.

The scroll distance is approximately 0.4% out. The further down the list of divs 开发者_开发百科I attempt to scroll to, the further out the calculation is. I have mitigated the issue by:

outerDiv.scrollTop(innerDiv.position().top * 1.004);

Is this just a rounding issue internal to jQuery? Has anyone else found this?

(And yes, the outer div is set to position: relative)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜