Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>The (pure CSS) solution so far</h2> <p>If you leave <code>height:auto;</code> and use fixed values of <code>max-height</code> you can simulate a transition:</p> <pre><code>.details-expanded { max-height: 300px; /* try to guess a max-height for your content */ } .details-collapsed { height: auto; max-height: 0; transition: max-height 500ms linear; /* pick a proportional duration */ } </code></pre> <p>Pay attention to the transition duration and <code>max-height</code> when the element is expanded. Play with the values until you get the wanted behavior.</p> <p>This way you can get a transition between two defined values (in the above example, from 0 to 300) while the <code>height</code> property will just "follow" the <code>max-height</code> transition and grow until it gets the content's size.</p> <hr> <h2>Demos</h2> <p><a href="http://jsfiddle.net/3RBQ4/" rel="noreferrer"><strong>DEMO 1</strong></a> - a working example of this solution</p> <p><a href="http://jsfiddle.net/H6L43/18/" rel="noreferrer"><strong>DEMO 2</strong></a> - just demonstration of what is going on in DEMO 1</p> <hr> <h2>Observations</h2> <p>For now transitions are implemented only between predefined values and I supposed it is because the engine cannot guess the initial or final value in some cases. What if you have a height transition which its final value is 50% but transition itself affects the parent's height somehow?! It would probably require several <a href="http://www.interactivebynature.com/2013.04.05.considering-browser-reflow" rel="noreferrer"><strong>reflow</strong></a> calculations on each frame causing performance issues. </p> <p><a href="https://stackoverflow.com/questions/3311299/webkit-transition-not-working-for-height/5368659#5368659"><strong>Like fabb said</strong></a>, the spec for CSS transitions determines that percentage values should be supported, so it might be just a matter of time until engines decides on which cases they're going to support transitions using dynamically valued points. Still, I'm not sure about what could be considered the correct behavior for <code>auto</code> values thought.</p>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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