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