I am experimenting with adding a transition effect to the details
element when it opens and closes:
details
{
height: 1em;
transition: height 2s;
border: 1px solid;
overflow: hidden;
white-space: pre;
}
details[open]
{
height: 6em
}
<details>
<summary>summary</summary>some
hidden
text
</details>
Currently, when the details open, it slowly expands to reveal the hidden text. However, when it closes, the text is instantly hidden and then slowly shrinks. I would prefer the text to be hidden by shrinking. Is there a way to achieve this using only CSS?