三者均用于获取一个Dom节点的高度,不过他们的含义并不相同。

clientHeight :

MDN对该属性的描述如下:

The Element.clientHeight read-only property returns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

clientHeight can be calculated as CSS height + CSS padding - height of horizontal scrollbar (if present).

  从描述可以知道,它是一个只读属性。表示一个Dom节点的内部(inner)高度,包括内填充,但不包括水平滚动条、边框和外边距。

offsetHeight:

MDN对该属性的描述如下:

The HTMLElement.offsetHeight read-only property is the height of the element including vertical padding and borders, in pixels, as an integer.

Typically, an element's offsetHeight is a measurement which includes the element borders, the element vertical padding, the element horizontal scrollbar (if present, if rendered) and the element CSS height.

For the document body object, the measurement includes total linear content height instead of the element CSS height. Floated elements extending below other linear content are ignored.

  包括内填充、边框和水平滚动条,不包括外边距。

scrollHeight:

MDN对该属性的描述如下:

The Element.scrollHeight read-only attribute is a measurement of the height of an element's content, including content not visible on the screen due to overflow. ThescrollHeight value is equal to the minimum clientHeight the element would require in order to fit all the content in the viewpoint without using a vertical scrollbar. It includes the element padding but not its margin.

  同样它也是一个只读属性。表示一个Dom节点的内容(content)高度,包括因溢出而不可见的内容,同样包括内填充,但不包括边框和外边距。

转载于:https://www.cnblogs.com/fly-could/p/3946889.html

javascript 之clientHeight、scrollHeight、offsetHeight相关推荐

  1. 这该死的高度,height,clientHeight,scrollHeight,offsetHeight

    引言: 虽然有时候界面的设置不是我们这些后台代码人员的工作,但是有时候却难以理解控件生成时的一些怪事,比方在学习webabcd的扩张GridView中固定列时,你或许已经被其中的height,clie ...

  2. clientHeight , scrollHeight , offsetHeight之间的区别及兼容方案

    clientHeight , scrollHeight , offsetHeight相信每个人都用过,可是每次用都要查一下到底哪个是文档大小哪个是视口大小,还有头疼的兼容问题. 先来官方的了解一下这三 ...

  3. heigh,clientHeight , scrollHeight , offsetHeight介绍

    height是element元素部分属性,值为字符型,而其他三种的值为数字型,JS获取方式document.body.style.height,如果写成document.body.height会提示u ...

  4. height clientHeight scrollHeight offsetHeight的大致区别

    这主要是针对火狐浏览器来讲的: height:就是div的高度,就是style中设置的高度:在chrome中clientHeight是包含padding的,offsetHeight和clientHei ...

  5. 【javascript】clientHeight,offsetHeight,scrollHeight,scrollTop的理解,以及触底函数

    1.clientHeight 含义:元素的像素高度,包含元素的高度+内边距,不包含水平滚动条,边框和外边距 图示: 2.offsetHeight 含义:元素的像素高度 包含元素的垂直内边距和边框,水平 ...

  6. 浏览器窗口尺寸clientHeight / scrollHeight / offsetHeight / innerHeight

    https://www.cnblogs.com/nanshanlaoyao/p/5964730.html clientHeight:元素客户区的大小,指的是元素内容及其边框所占据的空间大小(经过实践取 ...

  7. clientHeight、offsetHeight 和 scrollHeight

    2019独角兽企业重金招聘Python工程师标准>>> window.screen.availWidth 返回当前屏幕宽度(空白空间) window.screen.availHeig ...

  8. 再次详解clientHeight、offsetHeight、scrollHeight

    关于clientHeight.offsetHeight.scrollHeight window.screen.availWidth 返回当前屏幕宽度(空白空间) window.screen.avail ...

  9. css clientheight、offsetheight、scrollheight详解

    介绍 网上介绍clientheight.offsetheight.scrollheight的帖子很多,看后感觉明白了,一细想似乎又不明白了.为了获取更权威的解答,查阅了MDN 文档,希望能帮助后来人. ...

  10. [转载]offsetHeight , clientHeight, scrollHeight 区别

    我们这里说说四种浏览器对 document.body 的 clientHeight.offsetHeight 和scrollHeight的解释,这里说的是 document.body,如果是 HTML ...

最新文章

  1. Unix数据中心主宠儿
  2. 注册不上zookeeper无报错_Zookeeper 跨区高可用方案
  3. selenium | TypeError:object of type ‘WebElement’ has no len()
  4. 微信卡券 - 微信公众平台 整理笔记
  5. python numpy np.array_Python | numpy | np.split()与np.array_split()函数
  6. 01_SQlite数据库简介
  7. Linux设备树翻译计划
  8. aop实现原理_SpringAOP原理分析
  9. java私有成员的访问_java – 使用私有成员或公共访问器的方法
  10. python widnows mysql_Windows下python安装MySQLdb
  11. ping 丢包 网络摄像头_FIFA21 新加入网络连接监测功能
  12. oracle进程的作用,浅析Oracle10g新进程 MMON 和 MMNL的作用
  13. python turtle画房子详细解释_简述python的turtle绘画命令及解释
  14. 5G成鸡肋?运营商可能冷处理,中国移动则加快建设4G的FDD900
  15. Linux网络管理之ss命令– 显示活动套接字信息
  16. 编程实战(2)——Python解微分方程方法总结
  17. win10怎么查看自己笔记本电脑电池的损耗情况
  18. 图像超分之——寻找两张图差异的区域
  19. CRM项目第一天(2021-12-16)1
  20. 阿里云服务器web项目启动连接mysql_eclipse web项目部署到阿里云服务器

热门文章

  1. jdbc连接oracle rac服务器
  2. WCF之元数据交换 (Metadata Exchange)
  3. EasyNVR摄像机网页直播中,推流组件EasyRTMP推送RTMP扩展支持HEVC(H.265)的方案
  4. Mask_RCNN训练自己的模型(练习)
  5. BZOJ1975 [Sdoi2010]魔法猪学院 k短路
  6. MathType支持64位 WIN 7Office 2013(完美解决)(转载)
  7. Jquery调用webservice
  8. 关于datagridview自动增加行高度和显示全部内容的设置
  9. 如果你需要对对话框上的一个按钮进行鼠标停靠提示
  10. 第九周项目三-人数不定的工资类