测量窗口偏移量 [英] Measuring the window offset

查看:155
本文介绍了测量窗口偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在jQuery中测量窗口的偏移量,而不是比较固定元素和相对定位元素的位置?



<我需要能够分辨出窗口滚动的距离,以便我可以使用该图来计算固定元素(相对于视口顶部)的高度与相对对象(相对于文件的顶部)

解决方案

$(窗口).scrollTop() $(窗口).scrollLeft()可用于查找滚动位置。


Is there a way to measure the offset of the window in jQuery, in order than I might compare the positions of a 'fixed' element and a relatively positioned one?

I need to be able to tell how far the window is scrolled so I can use the figure to calculate the difference between the height of the fixed element (which is relative to the viewport top) and the relative object (which is relative to the top of the document)

解决方案

$(window).scrollTop() and $(window).scrollLeft() can be used to find scroll positions.

这篇关于测量窗口偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆