zoukankan      html  css  js  c++  java
  • JQ的尺寸类

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            .box{100px;height:100px;padding: 10px;border: solid 20px black;margin: 30px;position: absolute;left: 40px;top: 40px;overflow: auto;}
        </style>
    </head>
    <body>
    <div class="box">
        width()
    
        height()
    
        innerWidth() 包含内边距(padding)
    
        outerWidth()包含内边距和边框(     padding border)
    
        offset()  获取某个元素相对于浏览器窗口(可视区域的距离)
    
        position()获取某个元素相对于父元素的偏移距离
    
        scrollTop()获取垂直滚动条的值;
    
        scrollTop(value)设置垂直滚动条的值;
    
        scrollLeft()获取水平滚动条的值;
    
        scrollLeft(value)设置水平滚动条的值;
    </div>
    </body>
    <script src="../jquery.js"></script>
    <script>
        // 获取设置都可
         console.log($(".box").width())          //content 100
         console.log($(".box").innerWidth())          //content+padding 120
         console.log($(".box").outerWidth())          //content+padding+border 160
    
    //     $(".box").width(200) //设置为200
    
    
        // 只能获取不能设置
         console.log($(".box").offset())         //position+margin l:70 t:70
         console.log($(".box").position())         //position l:40 t:40
    //     $(".box").position({
    //         left:100,
    //         top:100
    //     }) //不能设置  没有用
    
    
            $(document).click(function(){
                 console.log($(".box").scrollTop()) //输出滚动条距离
                $(".box").scrollTop(333)          //设置距离高度
            })
    
    
    </script>
    </html>
  • 相关阅读:
    好记性不如烂笔头-linux学习笔记2kickstart自动化安装和cacti
    好记性不如烂笔头-linux学习笔记1
    关于TP5中的依赖注入和容器和facade
    vbs 脚本2
    vbs脚本
    Memcache 和 Radis 比较
    MongoDB 索引的使用, 管理 和优化
    mysql大数据高并发处理
    sql处理高并发
    LB 负载均衡的层次结构
  • 原文地址:https://www.cnblogs.com/hy96/p/11558145.html
Copyright © 2011-2022 走看看