获取元素相对于屏幕的位置

<div class="div1"></div>
    <script>
      //返回值是一个包含width height top right bottom left, x , y的对象
        var rect = document.querySelector('.div1').getBoundingClientRect()
     console.log(rect);
    </script>

  

posted @ 2018-03-08 14:24  高中国流  阅读(536)  评论(0编辑  收藏  举报