title: Image overflowing div advice
body: <p>Im sure this is really easy but i have been looking at this issue for a little while and my brain has gone blank. I have a div that then has an image inside of it. The image seems to just overflow the div border and its driving me mad. I have an image below to show you what is happening along with the css.</p>
  
  <p><img src="https://i.imgur.com/dkzoNCc.png" alt="image"></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-css lang-css prettyprint-override"><code>#avatar {
    float: left;
    width: 50%;
    height: 300px;
    border: 1px solid black;
  }
  
  #avatar img {
    width: 100%;
    height: auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="avatar"&gt;
  &lt;img src="http://i.imgur.com/dkzoNCc.png"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have a border on the main div #avatar just so i can see the whole size of the div. All i want is for the image to scale to the size of the div. If i set the height to 100% it goes into the div just fine but when resizing it it starts to overflow the div. I want the image to resize on the width not height.</p>
  
  <p>Am i missing something really simple here? I dont want to use overflow hidden on the image as that will just cut some of it off i believe.</p>
  
  <p>Thanks everyone</p>