美文网首页
js获取元素的DOMRect

js获取元素的DOMRect

作者: 米诺zuo | 来源:发表于2020-12-06 14:29 被阅读0次

The *Element.getBoundingClientRect()* method returns a DOMRect object providing information about the size of an element and its position relative to the viewport.

document.getElementsByClassName('outer').getBoundingClientRect()
//  {bottom: 111,height: 54,left: 2,right: 380.40625,top: 57,width: 378.40625,x: 2,y: 57}
document.getElementsByClassName('outer').attributes
//  {0: class, 1: debug, class: class, debug: debug, length: 2}
document.getElementsByClassName('outer').childElementCount
//  1
document.getElementsByClassName('outer').children
//  HTMLCollection[]

https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Syntax

相关文章

网友评论

      本文标题:js获取元素的DOMRect

      本文链接:https://www.haomeiwen.com/subject/nygaiktx.html