Check out this demo for reference: https://codepen.io/jchi2241/pen/dEzMZo?editors=1100
In my current setup, I use a max-height of 0 to hide the <ul>
element when the related input is unchecked. When checked, the max-height is set to 10em to reveal the content. The choice of using max-height allows for smooth opening and closing animations.
An issue that I've encountered is that even though the <ul>
has a max-height of 0, it still occupies space below the <label>
. This becomes apparent if the <ul>
is removed or positioned absolutely/displayed none, disrupting the flow of the document's structure. These options are not viable as they would hinder the transition effects.
To reiterate the main question - why does the <ul>
retain space below the <label>
despite having its height set to 0? How can this space be eliminated without compromising the animation transitions?