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: 内容层左边到可视区域左边的距离(被隐藏区域宽度)。

  • 相关阅读:
    01前端-html
    2-3程序流程
    2-2视频缓存池
    2-1图像像素格式深度理解
    3.1.1 文件系统介绍
    3.1.4 文件属性
    CentOS开放端口的方法
    宝塔linux面板命令大全
    如何卸载Win10 RS3上预装的office2016
    win10家庭版升级专业版的两种方法和密钥
  • 原文地址:https://www.cnblogs.com/huen2015/p/11050765.html
Copyright © 2011-2022 走看看