JS盒子模型图

1、client系列
clientWidth
盒子的宽width加上左右padding值
clientHeight
盒子的高Height加上上下padding值
clientLeft
左边框的宽度即左border
clientTop
上边框的宽度即上border
2、offset系列
offsetWidth
盒子的宽width加上左右padding值再加上左右边框border的宽度,也可以理解为clientWidth加上左右边框border的宽度
offsetHeight
盒子的高Height加上上下padding值再加上上下边框border的宽度,也可以理解为clientHeight加上上下边框border的宽度
offsetLeft
当前盒子的外边框到上级参照物内边框的距离
offsetTop
当前盒子的外边框到上级参照物内边框的距离
offsetParent
指的是上级参照物,上级参照物指的是有定位的上级元素(注意:上级参照物最多查询到body;body的上级参照物是null)
3、scroll系列
scrollWidth
内容不溢出,等同于clientWidth
scrollHeight
内容溢出时,但是没有overflow属性,盒子的上padding+内容的高度; 内容溢出,但是有overflow属性,盒子的上下padding+内容的高度;
scrollTop
卷去的内容的高度
scrollLeft
卷去的内容的宽度
注:以上13个属性,只有scrollTop和scrollLeft的属性时可以设置更改的,其他11个属性均为只读属性。