JS獲得元素相對位置坐標getBoundingClientRect()


 

getBoundingClientRect用於獲取某個元素相對於視窗的位置集合。集合中有top, right, bottom, left等屬性。

1.語法:這個方法沒有參數。

rectObject = object.getBoundingClientRect();
function inputKeydown(e){
  console.log(e.target.getBoundingClientRect());//bottom:199height:19left:360right:380top:180width:20x:360y:180
}

 


記錄一下備用:
https://www.cnblogs.com/Songyc/p/4458570.html





 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM