js 原生获取一个元素的距离,比较全的api

js 原生获取一个元素的距离,比较全的api

document.getElementById().getBoundingClientRect()

值的格式为

DOMRECT {
    bottom : 500 ,
    height : 17 ,
    left   : 311.5 ,
    right  : 391.5 ,
    top.   : 483 ,
    width  : 80,
    x      : 311.5,
    y.     : 483



}

猜你喜欢

转载自blog.csdn.net/qq_34849240/article/details/80709149