Loading...
details .content {
height: 0;
transition: height 0.3s;
}
details[open] .content {
height: auto;
}details::details-content {
block-size: 0;
overflow: hidden;
interpolate-size: allow-keywords;
transition: block-size 0.3s, content-visibility 0.3s allow-discrete;
}
details[open]::details-content {
block-size: auto;
}::details-content is the part that opens and closes, and 'allow-discrete' plus interpolate-size let it animate to 'auto'.
content-visibility isn't transitioned with 'allow-discrete'.<summary> with ::details-content, which covers only the content part.interpolate-size is treated as progressive enhancement, because it is not supported in every browser.content-visibility is in the transition list with transition-behavior: allow-discrete, so closing also animates.@media (prefers-reduced-motion: reduce).Yes, with ::details-content, interpolate-size: allow-keywords and a discrete transition on content-visibility. Where unsupported, it simply opens without animation.
Give the <details> elements the same name attribute. Opening one then closes the others in the group.