height、clientHeight、offsetHeight、scrollHeight、height()、 innerHeight()、outerHeight()等的区别
1.height
height是css属性,这个属性定义元素内容区的高度,在内容区外面可以增加内边距、边框和外边距。
当 box-sizing: content-box 时,高度应用到元素的内容框。
当 box-sizing:border-box时,高度包含了内容框、内边距和边框。
2.clientHeight
Element.clientHeight只读属性是没有的CSS或内联布局框元素为零,否则它的像素单元内的高度,但不包括填充水平滚动条的高度,边界或边缘。
// 包含元素的content+padding
dom.clientHeight
3.offsetHeight
Element.offsetHeight只读属性是元素包括垂直边距和边框的高度,为整数。
// 包含元素的content+padding+border
dom.offsetHeight
4.scrollHeight
Element.scrollHeight只读属性是测量一个元素的含量的高低,包括内容不可见的屏幕上由于溢出。
// 滚动高度
dom.scrollHeight

5.jQuery height()
height() 方法设置或返回元素的高度(不包括内边距、边框或外边距)。
6.jQuery innerHeight()
innerHeight() 方法返回元素的高度(包括内边距)。
7.jQuery outerHeight()
outerHeight() 方法返回元素的高度(包括内边距和边框)。
outerHeight(true) 方法返回元素的高度(包括内边距、边框和外边距)。
参考api:https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
参考文章:https://www.cnblogs.com/yuteng/articles/1894578.html
height、clientHeight、offsetHeight、scrollHeight、height()、 innerHeight()、outerHeight()等的区别的更多相关文章
- clientHeight ,offsetHeight,style.height,scrollHeight有区别与联系
		
style.height 包括 元素的滚动条,不包括边框clientHeight 不包括元素的滚动条和边框,只有在没有元素的滚动条的情况下,style.height相等于clientHeightoff ...
 - 关于height、offsetheight、clientheight、scrollheight、innerheight、outerheight的区别一览
		
平时,不管在pc端页面还是移动端页面,因为我们一般很少会设置某个块的的高度,但是呢,我有时候有需要取到这些高度以便于我们方便进行判断和下一步的编写.一般这个时候我都是直接的获取一个块的高度.heigh ...
 - clientHeight & offsetHeight & scrollHeight
		
clientHeight & offsetHeight & scrollHeight scrollWidth/scrollHeight,offsetWidth/offsetHeight ...
 - 关于height、offsetheight、clientheight、scrollheight、innerheight、outerheight的区别
		
二.也是平时经常用到的offsetheight 它返回的高度是内容高+padding+边框,但是注意哦,木有加margin哦,当然一般也木有啥需要把margin加进去的,以上代码为例,结果显示上图h2 ...
 - javascript - 所有的视图属性和方法(offsetHeight、clientHeight、scrollHeight、innerHeight等)
		
注意:本文只简单的介绍了各个视图的属性和方法.如果想要知道兼容性或者更多,请至文章底部参考链接处. 本文内容分为五大部分: Window视图属性 innerHeight 和 innerWidth ou ...
 - JavaScript获取浏览器高度和宽度值(documentElement,clientHeight,offsetHeight,scrollHeight,scrollTop,offsetParent,offsetY,innerHeight)
		
IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...
 - clientHeight,offsetHeight,scrollHeight迷一样的三个值
		
https://blog.csdn.net/qq_39083004/article/details/78498178 https://www.imooc.com/article/17571 推荐 o ...
 - 关于body/documentElement ---->clientHeight, offsetHeight, scrollHeight
		
http://blog.csdn.net/woxueliuyun/article/details/8638427 http://blog.sina.com.cn/s/blog_9dd702d50101 ...
 - 各种高度的区别及height、clientHeight、scrollHeight、offsetHeight的区分
		
1.height.clientHeight.scrollHeight.offsetHeight 我们来实现test中的onclick事件 function justAtest() { ...
 - height、clientHeight、scrollHeight、offsetHeight区别
		
转自 http://www.cnblogs.com/yuteng/articles/1894578.html 我们来实现test中的onclick事件 function justAtest() ...
 
随机推荐
- [转帖]SUSE Linux
			
历经坎坷多次易主,SUSE Linux路在何方? http://blog.itpub.net/11310314/viewspace-2638811/ 之前一直理不清楚 SUSE和RedHat的关系 甚 ...
 - CentOs7安装docker(第二篇)
			
一.Docker的概念: Docker: 镜像:Images 类似于面向对象中的类 容器:Container 类似于面向对象中的对象 它们之间的关系:容器Container通过镜像Images来创建 ...
 - C# Note3:大话Ninject
			
前言 之所以研究Ninject,是因为初入职在开发XX项目的ComponentService部分时用到了它,一下子发现了它的强大.渐渐地发现在项目中,有时会用到优秀的第三方开源库,这些都是前人智慧的结 ...
 - node 模块化思想中index.js的重要性
			
目录结构如上图 module1和modlue2.main在同一级 module1下文件: index.js var test2=require('./test2'); var sayHi=functi ...
 - Python 基础知识----数据类型
			
一.Number 类型(数值类型) 二.String 类型 (字符串类型) 三.List 类型 (列表类型) 是一种常用的序列类型簇,List 用中括号 [ ] 表示,不同的元素(任意类型的值)之间以 ...
 - Ubuntu中MySql的启动与关闭
			
安装mysql sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysqlcli ...
 - 关于Linux系统下jdk版本切换问题(alternatives命令的使用)
			
[root@danny lib]# cd /usr/lib/jvm [root@danny jvm]# [root@danny jvm]# ls java java--openjdk-.b13.el7 ...
 - python设计模式第二十天【迭代器模式】
			
1.不使用迭代器出现的问题 (1)容器承担了太多的功能,一方面提供添加和删除等功能,还需提供遍历访问功能 (2)在容器访问遍历过程中,需要保存遍历状态,当和元素的添加和删除混杂在一起时,容易引起混乱 ...
 - ajax获得后台传来的一个json值,在js中获得其中的属性值
			
首先 ajax的dataType需要设置为json, 默认的text获取属性值在jquery3.2.1中尝试不成功 获得属性值的方式: 类似数组,键值对的方式 下面例子: 设置dataType为jso ...
 - Ftp、Ftps与Sftp之间的区别
			
Ftp FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”.用于Internet上的控制文件的双向传输.同时,它也是一个应用程序(Applica ...