title: Why the canvas size in this code is not as expected?
body: <p><a href="https://jsfiddle.net/awguo/uw1x8m3y/" rel="nofollow">https://jsfiddle.net/awguo/uw1x8m3y/</a></p>
  
  <p>here is the detailed demo.</p>
  
  <p>I put an img in a div#wrapper and then put a canvas overlap on this img inside that wrapper. I set the width and height of the img and css both to 100%. Then I track the width*height of the canvas. It's not as expected (350x350) but 350x354. Why there is a "4px" more? What should I do to make the canvas size exactly the same as the image (which may also be stretched according to the parent div's width?</p>
  
  <p>Thanks!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() {
    // Why it's 350x354, not 350x350?
    var output = 'canvas size: ' + ($('#overlap').css('width') + ' x ' + $('#overlap').css('height'));
    $('#output').val(output);
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#wrapper {
    position: relative;
    width: 350px;
  }
  #wrapper img {
    width: 100%;
  }
  #overlap {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%
  }
  #output {
    width: 350px
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="wrapper"&gt;
    &lt;img src="http://www.awflasher.com/300x300_demo.png" /&gt;
    &lt;canvas id="overlap"&gt;&lt;/canvas&gt;
  &lt;/div&gt;
  
  &lt;h3&gt;
      Output:
      &lt;/h3&gt;
  &lt;input id="output" type="text" /&gt;
  
  &lt;p&gt;
    Why the output is 350x354, not 350x350 as expected?
  &lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>