$(document).height() 奇怪的行为
我需要动态评估文档的总高度以及窗口高度和滚动,以便准确定位移动元素。
我遇到的问题是 $(document).height() 似乎向我发送了错误的数字。
在页面刷新时,文档报告了一个数字,但是在调整窗口大小并将其放回原样后,该数字已更改超过 200px!
任何可能导致此问题的已知问题?
I need to assess the total height of a document on the fly, along with the window height and scroll in order to position a moving element accurately.
The trouble I am having is that $(document).height() seems to be sending me the wrong figure.
On the page refresh, the document reports one figure, but after resizing the window, and putting it back as it was, that figure has changed by over 200px!!
Any known issues that could cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据评论此处,
$( document ) .height()
不可靠。使用$( window ).height()
可能会获得更好的结果。According to comments here,
$( document ).height()
is unreliable. You may have better results using$( window ).height()
.