三大系列:offset,scroll,client

2020-01-03  本文已影响0人  长鲸向南

一,offset系列

1,offsetWidth

image

(根据数值计算也可以知道返回的宽度是元素的width+左右两个padding和左右两个border)

2,offsetHeight

image

3,offsetLeft

image image

4,offsetTop

image image

5,offsetParent

image image

二,scroll系列

1,scrollHeight

image image

2,scrollWidth

3,scrollTop

image

4,scrollLeft

image

5,兼容问题

function getScroll() {
        return {
            left: window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft || 0,
            top: window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop || 0
        };
    }

三、client系列

image

1,clientWidth

2,clientHeight

3,clientLeft

4, clientTop

5,clientX

6,clientY

image
上一篇 下一篇

猜你喜欢

热点阅读