首页 > 其他 > 详细

获取滚动条距离底部的距离

时间:2018-03-02 13:46:24      阅读:337      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>滚动条距离底部的距离</title>
    </head>
    <body>
        <div class="box">
            <div style="height:10000px;"></div>
        </div>
        <script>
            window.addEventListener(scroll,function(){
                console.log(document.documentElement.scrollTop);//代表目前滚动条和最上方的距离多长
                console.log(document.documentElement.scrollHeight);//代表整个滚动条多长
                console.log(document.documentElement.clientHeight);
                console.log(document.documentElement.scrollHeight-document.documentElement.scrollTop-document.documentElement.clientHeight);
            })
        </script>
    </body>
</html>

 

获取滚动条距离底部的距离

原文:https://www.cnblogs.com/rachelch/p/8492562.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!