js获取某个元素的宽高

   let gapPic = document.getElementById('gapPic')
   let rect = gapPic.getBoundingClientRect() // 获取宽高
   console.log(rect.width, rect.height)

 

posted @ 2025-06-12 09:19  yw3692582  阅读(14)  评论(0)    收藏  举报