转:https://www.cnblogs.com/lixia...关于元素大小和位置的一些属性。有:clientLeft和clientTopclientWidth和clientHeightoffsetLeft和offsetTopoffsetParentoffsetWidth和offsetHeightscrollLeft和scrollTopsscrollWidth和scrollHeight详细解释:1.clientLeft和clientTopclientLeft,clientTop:表示内容区域左上角相对于整个元素左上角的位置(包括边框)。(取决于边框的图像值?)2.clientWidth和clientHeightclientWidth,clientHeight:内容区域的宽度和高度,不包括边框宽度值。3.offsetLeft和offsetTopoffsetLeft、offsetTop:相对于最近的祖先定位元素。4.offsetParentoffsetParent:一个元素的父元素例如:this.offsetParent.tagName.toLowerCase()获取body...5.offsetWidth和offsetHeightoffsetWidth,offsetHeight整个元素的大小(不包括可变width的宽度)6.scrollLeft和scrollTopscrollLeft、scrollTop:元素滚动大小7.scrollWidth和scrollHeightscrollWidth、scrollHeight:整个内容区域的宽度(包括需要拉动滚动条隐藏的部分)scrollTop+clientWidth类似的属性进一步区分:1.scroll-相关属性scrollWidth:获取对象的滚动宽度scrollHeight:获取对象的滚动高度。scrollLeft:设置或获取对象左边界与窗口当前可见内容最左端的距离scrollTop:设置或获取最顶层对象与窗口最顶层可见内容的距离2.offset相关属性offsetHeight:对象相对于布局或offsetParent的高度(可见部分的宽度加上滚动条实体的宽度)offsetWidth:对象相对于布局或offsetParent的宽度offsetLeft:得到计算出的左边theobjectrelativetothelayoutorparentcoordinatespecifiedbyoffsetParentattribute侧边位置offsetTop:获取计算出的对象相对于layout或offsetTop属性指定的父坐标的top位置。event.offsetX是相对于容器的水平坐标。event.offsetY是相对于容器的纵坐标。可见部分的宽度)clientHeight:相对文档高度event.clientX相对文档水平坐标event.clientY相对文档垂直坐标4.scroll相关属性scrollHeight:对象的滚动高度(滚动条的高度,scrollableHeight)scrollWidth:对象的滚动宽度(同上)scrollLeft:对象左边框到窗口中当前可见内容左端的距离(滚动条已经滚动的距离)scrollTop:顶部到顶部的距离窗口中对象的顶部和可见内容之间的距离(同上)
