js element offset, client, scroll three series summary

1, element.offsetWidth: including padding and border

2, element.clientWidth: including padding, does not include the border, beyond the contents of the box when it will overflow, use scrollWidth

3, element.scrollWidth: does not include the border

The main usage:

1, offset series is often used to obtain the element position offsetLeft offsetTop

2, client frequently used to obtain the element size, clientWidth, clientHeight

3, scroll often used to get rolling distance, scrollTop scrollLeft

4, pay attention to page scrolling distance obtained by window.pageXoffset window.pageYoffset

Guess you like

Origin www.cnblogs.com/shanlu0000/p/11506390.html
Recommended