title: CSS height transition without a final state?
body: <p>I have the following html and css code that works exactly as I expect it to.</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 toggle() {
    var el = document.getElementById("panel");
    el.className = el.className == "expanded" ? "collapsed" : "expanded";
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.collapsed {
    height: 0px;
  }
  .expanded {
    height: 500px;
  }
  #panel {
    overflow: hidden;
    transition: height 1s linear;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p id="panel" class="expanded"&gt;
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
    survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
    software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it
    has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
  &lt;/p&gt;
  &lt;button onClick="toggle()"&gt;Toggle Panel&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <hr>
  
  <p>Clicking on the button will slide up or slide down the panel with a 1 second height transition effect.</p>
  
  <p>However, if I replace the expanded height 500px with auto, inherit or initial, the height transition no longer takes effect.  The panel just snaps between 0px and the original height.</p>
  
  <p>I plan to have text of various length, and it will not be feasible to custom define a height for every single paragraph.  Is there a CSS only approach to still do the sliding animation without explicitly defining the height of the panel?</p>