js 获取dom元素距离顶部的位置
// js 获取dom元素距离顶部的位置 let divOneTop = document.getElementById('div-one').getBoundingClientRect().top let divTwoTop = document.getElementById('div-two').getBoundingClientRect().top let divThreeTop = document.getElementById('div-three').getBoundingClientRect().top // 监听浏览器窗口变化的方法函数 window.onresize = function () { // 浏览器的可视区域高度 let innerHeight = window.innerHeight let threeHeight = innerHeight - divThreeTop document.getElementById('div-three').style.height = threeHeight + 'px' document.getElementById('div-three').style.backgroundColor = 'red' }
我不制造bug,我只是bug的搬运工。