如何计算元素的top和left

2018-04-11  本文已影响0人  东方灵将
let search = document.getElementById('kw');
let rect = search.getBoundingClientRect();
let bodyRect = document.body.getBoundingClientRect();
let top = rect.top - bodyRect.top
let left = rect.left - bodyRect.left
上一篇下一篇

猜你喜欢

热点阅读