window.onload = function() { var ele = document.getElementById('rect') var big = document.getElementById('big') big.onclick=function() { console.log(ele.getBoundingClientRect().left) console.log(ele.getBoundingClientRect().right) } }
<div id="rect"></div> <div id='big'>查看结果</div>
#rect { width: 200px; height: 200px; background: orange; } #big { width: 120%; background: pink; }