I’m making the suggestion here as well, as requested by Alan Cutter:
When creating a disclosure widget:
<p><a href="#widget">Show Terms & Conditions</a></p>
<div id="widget">
<p>Long legal text, hidden by default.</p>
</div>
Developers used to use jQuery to display the hidden content with a height changing animation (so the content did not suddenly appear):
$('#widget').slideToggle();
More recently we have been using CSS animations:
#widget {
overflow-y: hidden;
max-height: 500px; /* approximate max height */
transition-property: all;
transition-duration: .5s;
}
#widget.closed {
max-height: 0;
}
Where max-height
has to be guessed (not too high, as the animation will be too fast, and not too small, as content will be unreadable).
So can we take the max-content
suggestion for the auto-resizing iframe, and allow it to work on the max-height
(or height
) properties:
#widget {
max-height: max-content;
}
This is related to the iframe and textarea resize requests:
Where I also have a working demo:
https://craigfrancis.github.io/iframe-height/additional/height-animation/