Comments on: Transitioning to Auto Height https://css-tricks.com/transitioning-to-auto-height/ Tips, Tricks, and Techniques on using Cascading Style Sheets. Fri, 12 Jul 2024 10:27:31 +0000 hourly 1 https://wordpress.org/?v=6.5.5 By: Yair Even Or https://css-tricks.com/transitioning-to-auto-height/#comment-1845664 Fri, 12 Jul 2024 10:27:31 +0000 https://css-tricks.com/?p=378862#comment-1845664 I also wrote on Stackoverflow about this regarding the transitioning of the display property: https://stackoverflow.com/a/78304935/104380

]]>
By: basher https://css-tricks.com/transitioning-to-auto-height/#comment-1831341 Mon, 01 Jul 2024 08:43:12 +0000 https://css-tricks.com/?p=378862#comment-1831341 Yay. CSS animations for opening/closing <details><summary> blocks without a line of JS!

]]>
By: Martin Winkler https://css-tricks.com/transitioning-to-auto-height/#comment-1831331 Sun, 30 Jun 2024 12:11:22 +0000 https://css-tricks.com/?p=378862#comment-1831331 First I want to point out a typo that threw me off (until I understood that there’s a typo)
> […] but it actually does have a computed height or auto unless a specific height is declared on it.

“computed height or auto” should be “computed height of auto”

And second: I think you got the explanation wrong why transition-behavior: allow-discrete; is needed when display: none; is involved. It seems in Chris’ article the part that switches from display: none to display: something was omitted or at least I didn’t see it, but as far as I understood it, the style or code that sets it would switch the property immediately, so we would never be able to see a closing animation of height. With transition-behavior: allow-discrete; the actual switch to display: none takes effect only after any animation / transition has finished. (And it behaves the other way around when a style changes an element from display: none to display: something.)
The @starting-style is needed because as you have mentioned an element with display: none ends up being renderd with a computed style of height: auto regardless of the property set to height: 0 via the style. Unintuitive yes, but probably ancient, spec’d, established browser behavior.
Which would mean that we would attempt to transition from auto to auto which will do nothing. Hence @starting-style { height: 0; }.
And third: thank you for the article.

]]>
By: TFL https://css-tricks.com/transitioning-to-auto-height/#comment-1831330 Sun, 30 Jun 2024 09:38:51 +0000 https://css-tricks.com/?p=378862#comment-1831330 Didn’t we already figure this out with css-grid?:

CSS Grid Can Do Auto Height Transitions

]]>
By: Matthew Dean https://css-tricks.com/transitioning-to-auto-height/#comment-1831173 Sat, 29 Jun 2024 16:08:39 +0000 https://css-tricks.com/?p=378862#comment-1831173 Not many people know it, but this use case was already supported with CSS grid. A grid with an unspecified height has grid tracks with a height of 1fr. So, you can transition from 0fr to 1fr smoothly.

]]>
By: Joe Morgan https://css-tricks.com/transitioning-to-auto-height/#comment-1830861 Fri, 28 Jun 2024 21:43:37 +0000 https://css-tricks.com/?p=378862#comment-1830861 I was using @starting-style a few months back to animate in the display of a native <dialog> (nothing crazy, just opacity and translate), and it kept causing chrome tabs to crash with the “Aw snap” message.

So be careful out there on the edge, folks.

]]>
By: Nicola https://css-tricks.com/transitioning-to-auto-height/#comment-1830860 Fri, 28 Jun 2024 17:49:53 +0000 https://css-tricks.com/?p=378862#comment-1830860 This is amazing. Countless times I have wished auto could be a viable animation target.

]]>