美文网首页
getBoundingClientRect

getBoundingClientRect

作者: 如果俞天阳会飞 | 来源:发表于2019-04-13 16:51 被阅读0次

getBoundingClientRect用于获取某个元素相对于视窗口的位置集合,集合中有top right bottom left width height x , y等属性

1.语法:这个方法没有参数。

    rectObject = object.getBoundingClientRect();

2.返回值类型:
 rectObject.top:元素上边到视窗上边的距离;

rectObject.right:元素右边到视窗左边的距离;

rectObject.bottom:元素下边到视窗上边的距离;

rectObject.left:元素左边到视窗左边的距离;


image.png

这个属性在ie5就开始支持,

相关文章

网友评论

      本文标题:getBoundingClientRect

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