title: No CSS transition for 'height: fit-content'
body: <p>I use <code>transition: height 500ms</code> to add an animation to an element that slides open via button from <code>height: 0</code> to <code>height: 100px</code> and vice versa.</p>
  
  <p>Since the element's content is added dynamically and I don't know it's size I would like to switch to <code>height: fit-content</code> instead. This way the element would have always the right size to show it's content.</p>
  
  <p>Sadly this disables the animation.</p>
  
  <p><strong>How can I get the animation together with a div element which size fits its content?</strong></p>
  
  <p>Following snippet shows the behavior:</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>document.querySelector('button')
    .addEventListener(
      'click',
      () =&gt; document.querySelectorAll('div')
        .forEach(div =&gt; div.classList.toggle('closed')));</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>div {
    background-color: lightblue;
    border: 1px solid black;
    overflow: hidden;
    transition: height 500ms;
  }
  
  div.closed {
    height: 0 !important;
  }
  
  div.div1 {
    height: 100px;
  }
  
  div.div2 {
    height: fit-content;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button type="button"&gt;toggle&lt;/button&gt;
  
  &lt;h1&gt;'height: 100px' =&gt; 'height: 0'&lt;/h1&gt;
  &lt;div class="div1"&gt;
  some text&lt;br /&gt;
  even more text&lt;br /&gt;
  so much text
  &lt;/div&gt;
  
  &lt;br&gt;
  
  &lt;h1&gt;'height: fit-content' =&gt; 'height: 0'&lt;/h1&gt;
  &lt;div class="div2"&gt;
  some text&lt;br /&gt;
  even more text&lt;br /&gt;
  so much text
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>