elem.getBoundingClientRect()

110 阅读1分钟

elem.getBoundingClientRect(): 获取元素的宽高(具体跟盒模型有关)和每条边到视口端的距离(分别对应4个方向的偏移量)

参考