clientWidth、offsetWidth、scrollWidth的区别 March 4, 2020 #### clientWidth和clientHeigh 、 clientTop和clientLeft - clientWidth = width+左右padding - clientHeigh = height + 上下padding - clientTop = boder.top(上边框的宽度) - clientLeft = boder.left(左边框的宽度) #### offsetWidth和offsetHight 、 offsetTop和offsetLeft + offsetWidth = width + 左右padding + 左右boder + offsetHeith = height + 上下padding + 上下boder + offsetTop:当前元素上边框外边缘到最近的已定位父级(offsetParent)上边框内边缘的距离。如果父级都没有定位,则分别是到body顶部和左边的距离 + offsetLeft:当前元素左边框外边缘到最近的已定位父级(offsetParent)左边框内边缘的距离。如果父级都没有定位,则分别是到body顶部和左边的距离 #### scrollWidth和scrollHeight 、 scrollTop和scrollLeft + scrollWidth:获取指定标签内容层的真实宽度(可视区域宽度+被隐藏区域宽度) + scrollHeight:获取指定标签内容层的真实高度(可视区域高度+被隐藏区域高度) + scrollTop :内容层顶部 到 可视区域顶部的距离 + scrollLeft:内容层左端 到 可视区域左端的距离