title: svg with absolute positioning and height misbehaves in Chrome
body: <p>The following HTML file produces something peculiar in Chrome depending if the line <code>$("#canvas").height(100);</code> is commented or not.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
          &lt;div style="margin-right: auto; margin-left: auto; width: 940px;"&gt;
              &lt;div&gt;&lt;h1&gt;Title&lt;/h1&gt;&lt;/div&gt;
              &lt;div style="height: 50px;"&gt;&lt;/div&gt;
              &lt;svg id="canvas" style="width: 100%; position: absolute; left: 0px; z-index: -1;"&gt;
                  &lt;rect id="rect" x="0" y="0" width="100" height="100" fill="none" stroke-width="1" stroke="black"/&gt;
              &lt;/svg&gt;
              &lt;div id="div1"&gt;Hi&lt;/div&gt;
              &lt;div id="div2"&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
              function move() {
                  var left = $("#div1")[0].getBoundingClientRect().left;
                  $("#div2").text('left = ' + (left - 5));
                  $("#rect").attr("x", left - 5);
                  $("#canvas").height(100);
              }
  
              move();
  
              $(window).resize(function() {
                  move();
              });
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When loading the page in a maximized Chrome window then depending on the resolution, the div's text changes to <code>left = N</code>. It turns out this value of <code>N</code> is off by 7. This can be seen by resizing the window so it's not maximized and then maximizing it again.</p>
  
  <p>This strange behavior doesn't show up when the line <code>$("#canvas").height(100);</code> is commented out. You can witness this in this jsfiddle: <a href="http://jsfiddle.net/jvPCM/1/" rel="nofollow noreferrer">http://jsfiddle.net/jvPCM/1/</a>. You'd have to widen the Result pane to the left until the rect isn't close to the left edge and then hit refresh to see the incorrect drawing. It will be fixed if you resize the pane again. Here how it looks:</p>
  
  <p>Good: <img src="https://i.stack.imgur.com/OD3wP.jpg" alt="enter image description here"> Bad: <img src="https://i.stack.imgur.com/uaPUm.jpg" alt="enter image description here"></p>
  
  <p>What can cause this?</p>
  
  <p>FYI: This doesn't show up in Firefox (which ironically required setting the height in the first place).</p>