getBoundingClientRect

东明兄 2018-09-15
0条评论 1,134 次浏览
东明兄 2018-09-150条评论 1,134 次浏览

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

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注