首页 > 其他分享 >getClientRects 和 getBoundingClientRect()

getClientRects 和 getBoundingClientRect()

时间:2022-09-29 20:11:44浏览次数:39  
标签:getClientRects right getBoundingClientRect 元素 JS 获取

JS getClientRects 和 getBoundingClientRect()

  • getClientRects获取元素占据页面的所有矩形区域
  • getBoundingClientRect该方法用于计算获取的dom元素各边与上、左容器边框之间的距离,返回一个对象{ left, top, right, bottom }

标签:getClientRects,right,getBoundingClientRect,元素,JS,获取
From: https://www.cnblogs.com/jia-zq/p/16742883.html

相关文章

  • JS | getBoundingClientRect()方法的基本使用
    Element.getBoundingClientRect()方法返回一个DOMRect对象,其提供了元素的大小及其相对于视口的位置。返回的对象中有几个只读属性:width/x:元素矩形的宽度height/y......