scrollHieght、offsetHeight、clientHeight、width、height

1、scroll滚动(scrollTop、Left、Height、Width)

scroll()当用户滚动指定的元素时,会发生 scroll 滚动事件;

scrollWidth、scrollHeight属性表示元素对象真实的宽高;

scrollTop() 方法设置返回被选元素的垂直滚动条位置。当滚动条位于最顶部时,位置是 0。

scrollHeight-scrollTop=clientHeight;表示垂直滚动条走到底了(前提marginpadding都为0)

2、client 客户端(clientWidth、clientHeight)

浏览器的宽度:document.body.clientWidth;

3、offset偏移(offsetHeight、offsetWidth、offsetTop、offsetLeft)

offsetHeight、offsetWidth:表示当前对象的高、宽。

offsetTop、offsetLeft:表示当前元素对象相对于其定位元素的垂直、水平偏移量;

offset()可返回、可设置元素的偏移坐标

$(selector).offset():获取某元素当前的方位,返回偏移坐标;

$(selector).offset({top:value,left:value})设置偏移坐标

$(selector).offset().left 返回偏移坐标距离左边的位移

$(selector).offset($(selector).offset())使用另一元素的偏移坐标为元素设置偏移坐标

4、$(window).width();获取浏览器的宽度

     $(window).height();获取浏览器的高度

     $("#xx").width()/height()获取元素的宽度/高度

原文地址:https://www.cnblogs.com/colorful-paopao1/p/8342555.html