zoukankan      html  css  js  c++  java
  • 计算高度的常用值

    $(window).scrollTop();      滚动条距顶部距离(页面超出窗口的高度)

    $(document).scrollTop();     滚动条到顶部的垂直高度

    $(document).height()             页面的文档高度

    $(window).height()              窗口的高度

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>高度</title>
    <script src="http://files.cnblogs.com/tinyphp/jquery-1.3.2.min.js" type="text/javascript"></script>
    </head>
    
    <body>
    <script type="text/javascript">
    $(function(){
        $(window).scroll(function(){
        console.log("滚动条到顶部的垂直高度: "+$(document).scrollTop());
        console.log("页面的文档高度 :"+$(document).height());
        console.log('窗口的高度:'+$(window).height());
        console.log('滚动条距顶部距离(页面超出窗口的高度)'+$(window).scrollTop());
        console.log('----------------------------------');
        })
    })
    </script>
    <div class="box" style="height:800px; background:red"></div>
    </body>
    </html>
  • 相关阅读:
    PHP Mysql 根据一个给定经纬度的点,进行附近地点查询–算法 转载
    使用正则表达式匹配JS函数代码
    随便写点
    test
    Dat
    数据格式
    recod
    扫描
    转载 ASP.NET MVC中使用ASP.NET Identity
    制作32位和64位整合的安装包
  • 原文地址:https://www.cnblogs.com/tinyphp/p/3736399.html
Copyright © 2011-2022 走看看