Here's the demo: https://codepen.io/jchi2241/pen/dEzMZo?editors=1100
I am hiding the <ul>
with a max-height of 0 when the sibling input element is unchecked, and setting the <ul>
max-height to 10em when checked. I am using max-height specifically to animate the opening and closing for each section.
However, what I've realized is the <ul>
is taking up a noticeable amount of space below the <label>
even when the max-height is 0. This is obvious if you delete the <ul>
element or set the <ul>
to position: absolute
or display: none
taking it out of the DOM flow. I don't want to use either methods as that will not allow for the transition animation.
So to get back to the original question - what is causing the <ul>
to take up space below the <label>
even when it's height is set to 0? What is the ideal way to rid of this space while maintaining the transition animation?