getBoundingClientRect的用法

语法

  • rectObject = object.getBoundingClientRect();

element.getBoundingClientRect()方法返回元素的大小及其相对于可视窗口的位置。

返回值

返回值是一个Obj
Obj.top:元素上边到视窗上边的距离;
Obj.right:元素右边到视窗左边的距离;
Obj.bottom:元素下边到视窗上边的距离;
Obj.left:元素左边到视窗左边的距离;
如图:
getBoundingClientRect()

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-09-17
  • 2021-06-27
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-08
  • 2021-10-29
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案