关于offsetWidth、clientWidth与scrollWidth

三大系列对比

图示

他们的主要用法:

1. offset系列经常用于获得元素位置 offsetLeft    offsetTop;

2. client经常用于获取元素大小 clientWidth      clientHeight;

3. scroll经常用于获取滚动距离 scrollTop     scrollLeft;

4.注意页面的滚动距离通过 window.pageXOffset 获得。

原文地址:https://www.cnblogs.com/cy1227/p/13050631.html