Possible to make parent honour width of child image?
<p>I am trying to make a parent element honour the width of a child image.</p>

<p>It works on load, but if you resize the height of the viewport to force a change in the image height, the parent element 'remembers' the initial size of the image and maintains that width.</p>

<p>If you mimic the above with width instead of height, there is no problem.</p>

<p>Here is a video of the behaviour: <a href="http://jmp.sh/8VEOZS8" rel="nofollow">http://jmp.sh/8VEOZS8</a></p>

<p>Here is a codepen: <a href="http://codepen.io/iamkeir/pen/YWgvdw" rel="nofollow">http://codepen.io/iamkeir/pen/YWgvdw</a></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>html, body { height: 100%; }

.wrapper {
  display: inline-block;
  height: 100%;
  border: 1px solid black;
}

img {
  height: 100%;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="wrapper"&gt;
  &lt;img src="http://placehold.it/1280x960" /&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>I'm interested to know:</p>

<p>1) why this is happening</p>

<p>2) if there is a way to fix it</p>

<p>Thanks!</p>