getBoundingClientRect

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
版权声明:
作者:东明兄
链接:https://blog.crazyming.com/note/2098/
来源:CrazyMing
文章版权归作者所有,未经允许请勿转载。


共有 0 条评论