title: How to calculate position for div with absolute when browser window change width
body: <p>I have img and div under it with position absolute. So I need that this div always start from bottom right corner of image and go to left. But div gets off from img bottom corner after resize browser window when I use this code : </p>
  
  <pre><code>div1.style.left = ((imgRect.left + 
    (window.pageXOffset || document.body.scrollLeft) - 
    (document.body.clientLeft || 0)) 
    - 532) + "px";
  </code></pre>
  
  <p>Note that div take correct position when refresh the page, but how to do this without refreshing?</p>
  
  <p>I try to add this code:  </p>
  
  <pre><code>$(window).resize(function () { 
    div1.style.left = ((imgRect.left + 
      (window.pageXOffset || document.body.scrollLeft) - 
      (document.body.clientLeft || 0)) 
      - 532) + "px";
  });
  </code></pre>
  
  <p>but still have same result. I guess it is not a correct calculation.</p>