Element.getBoundingClientRect()方法返回元素的大小及其相对于视口的位置。
object.getBoundingClientRect().top:元素上边到视窗上边的距离
object.getBoundingClientRect().right:元素右边到视窗左边的距离
object.getBoundingClientRect().bottom:元素下边到视窗上边的距离
object.getBoundingClientRect().left:元素左边到视窗左边的距离
object.getBoundingClientRect().width:元素宽度
object.getBoundingClientRect().height:元素高度
object.getBoundingClientRect().x:用于left
object.getBoundingClientRect().y:用于top
1.如需转载本站原创文章,请务必注明文章出处并附上链接,非常感谢。
2.本站用于记录个人 工作、学习、生活,非商业网站,更多信息请 点击这里