Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any perspectives on height auto for CSS3 transitions and animations?

Tags:

CSS3 transitions, transforms and animations are wonderful. They are even more now more browsers do support them.

Still there's one thing I keep asking myself: Why isn't the spec definining that CSS3 transitions and animations should handle height:auto?

It doesn't make any sense when we're moving away from fixed layouts with things like the CSS3 flexible box model and media queries.

It doesn't make any sense to use JavaScript just to set a CSS transition with a fixed height.

Now comes my question:

Will the W3C ever specify that height:auto should be supported for CSS3 transitions and animations or can we request them to specify this?

like image 378
DADU Avatar asked Jun 02 '11 23:06

DADU


People also ask

Can you transition height in CSS?

We can't transition height , but we can transition max-height , since it has an explicit value. At any given moment, the actual height of the element will be the minimum of the height and the max-height .

How do you animate height in CSS?

For animate the "height" of element with CSS Transitions you need use "max-height". If use the "height: auto", the effect not works. Is necessary some value for the CSS create a CSS animate, and you can use "max-height" with a great value for emulate this effect.

Why do you use CSS3 transitions?

CSS Transitions allow property changes in CSS values to occur smoothly over a specified duration. This smoothing animates the changing of a CSS value when triggered by a mouse click, focus or active state, or any changes to the element (including even a change on the element's class attribute).

Which CSS property is used for transition effect?

The transition-property CSS property sets the CSS properties to which a transition effect should be applied.


2 Answers

You can transition max-height instead: http://jsfiddle.net/leaverou/zwvNY/

like image 89
Lea Verou Avatar answered Sep 24 '22 17:09

Lea Verou


I'm not sure why they didn't say anything about auto values either, but you can try asking them through their public CSS mailing list. As the transition and animation specs are still working drafts, they might just toss in some changes to address this matter. Good luck!

like image 35
BoltClock Avatar answered Sep 23 '22 17:09

BoltClock