I have an html container element which has children, some of which are of the css class child-active
.
The container should only be as tall as the largest active child. i.e. I want a container's max-height
to always be the largest height
of its children which are of the class child-active
. (The reason I want this is because it would solve a css transition issue for me).
I want something like:
.container {
max-height: calc(max(/* all the heights of .container > .child-active*/));
}
.child {
...
}
.child-active {
...
}
<div class="container">
<div class="child"> the height of this content is ignored </div>
<div class="child child-active"> the height of this content sets the height of the container </div>
</div>
Is this possible to do? Obviously I anticipate it will involve JavaScript.