I have a <details> element and I have an opening and closing animation for it. The closing animation won't play because the element closes immediately.
Here is some sample code:
details { background: pink; /* for demo purposes */ overflow: hidden; }
details[open] {
animation: sweep .5s ease-in-out;
animation-fill-mode: forwards;
}
details[closed] {
animation: unsweep .5s ease-in-out !important;
animation-fill-mode: forwards;
}
@keyframes sweep {
from {
height: 27px;
}
to {
height: 220px;
}
}
@keyframes unsweep {
from {
height: 220px;
}
to {
height: 27px;
}
}
@keyframes fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<details>
<summary>Test</summary>This is a very cool test :)
<br>woah
<br>woah
</details>