zoukankan      html  css  js  c++  java
  • JS中的位置和宽度:clientWidth、offsetWidth、scrollWidth等区别

    1、client

    clientWidth: width + 左右padding。

    clientHeight: height + 上下padding。

    clientTop: 上边框的厚度。

    clientLeft: 左边框的厚度。

    2、offset

    offsetWidth: width + 左右padding + 左右border。

    offsetHeight: height + 上下padding + 上下border。

    offsetTop: 当前元素上边框外边缘到最近的已定位父级(offsetParent) 上边框内边缘的距离。如果父级都没有定位,则分别是到body顶部的距离。

    offsetLeft: 当前元素左边框边缘到最近的已定位父级(offsetParent)左边框内边缘的距离。如果父级都没有定位,则分别是到body左边的距离。

    3、scroll

    scrollWidth: 获取指定标签内容层的真实宽度(可视区域宽度+被隐藏区域宽度)。

    scrollHeight: 获取指定标签内容层的真实高度(可视区域高度+被隐藏语气高度)。

    scrollTop: 内容层顶部到可视区域顶部的距离(被隐藏区域宽度)。

    scrollLeft: 内容层左边到可视区域左边的距离(被隐藏区域宽度)。

  • 相关阅读:
    getopt for windows
    开源代码学习之Tinyhttpd
    GCC 中的编译器堆栈保护技术
    读《程序员的思维修炼》有感
    main之前初始化流程
    平均速度
    显示图案
    圆的面积和周长
    C#(Winform) Http 发送数据
    Android BaseAdapter的使用
  • 原文地址:https://www.cnblogs.com/huen2015/p/11050765.html
Copyright © 2011-2022 走看看