Per this jsfiddle I have a parent element that, after some time, gets a child element added to become taller. However the CSS on the parent element doesn't change - the parent just grows to fit the child.
<section>
<div>
Hello world
</div>
</section>
section {
border: 2px red dotted;
height: 20px;
transition: all 0.2s ease-in-out;
}
section.isExpanded {
height: auto;
}
setTimeout(() => {
const section = document.querySelector('section')
var newElement = document.createElement('div');
newElement.textContent = "new content";
section.appendChild(newElement)
section.classList.add("isExpanded")
}, 3 * 1000)
Is it possible to use CSS transitions to animate the parent's growth when a child is added, even if the parent element's CSS doesn't actually change?