Note that there are some explanatory texts on larger screens.

plurals
  1. POImage width:auto and max-height after changing parent block height
    primarykey
    data
    text
    <p>Please see example in chrome. I try to implement row height animation with image that shouldn't exceed parent block.</p> <p>Why does image width change only after changing any property <a href="http://jsfiddle.net/JW3xX/2/" rel="nofollow">example</a>?</p> <p>Try to click the first button, image height will updated, but width no. Then click the second button, opacity will changed, and image width will be setted properly.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Image resizing&lt;/title&gt; &lt;style&gt; .header-row { width:900px; height:90px; margin:0 auto; background:#0f3a51; -webkit-transition: all .9s ease; -moz-transition: all .9s ease; -ms-transition: all .9s ease; -o-transition: all .9s ease; transition: all .9s ease; } .header-row img { display: inline; max-height: 100%; background:#ff9900; } .header-row-reduced { height:50px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="hr" class="header-row"&gt; &lt;img id="img" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Volkswagen_Logo.png/600px-Volkswagen_Logo.png" alt=""&gt; &lt;/div&gt; &lt;button id="btn" onclick="check();"&gt;Update row height&lt;/button&gt; &lt;button id="btn" onclick="changeProp();"&gt;Toggle opacity&lt;/button&gt; &lt;script&gt; var el = document.getElementById('hr'), img = document.getElementById('img'); function check(){ var classes = el.className.split(' '), hasClass = classes.indexOf('header-row-reduced'); if(~hasClass) { classes.splice(hasClass,1); } else { classes.push('header-row-reduced'); } el.className = classes.join(' '); } function changeProp() { img.style.opacity = '0.5'; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload