`
liujiawinds
  • 浏览: 131769 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

scrollTop 和 scrollHeight的意思

 
阅读更多

今天要用到实时显示最近更新内容,也就是要让对话框随时都在最底部。

查了一下,

用div.scrollTop=div.scrollHeight;就可以了。

又查了查这两个参数什么意思。stackoverflow上面有人是这样解答的。


If I scroll down 5px in this window, the window's scrollTop value is 5. If I scroll right 10px in a scrollable div, the div's scrollLeft value is 10.

When I scroll to the top left corner of this window, both its scrollTop and scrollLeft values are 0.

还有一个人作了补充: scrollTop and scrollHeight. In summary, scrollTop is how much it's currently scrolled, and scrollHeight is the total height, including content scrolled out of view.

总的来说,scrollTop就是卷起来的部分,也就是我们随着下拉,看不见的部分。scrollHeight就是整个窗口可以滑动的高度。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics