20

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?

4

3 に答える 3

27

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

于 2011-06-03T15:30:49.273 に答える
9

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!

于 2011-06-02T23:42:10.317 に答える
3

I think I've found a solution:

http://jsfiddle.net/adambiggs/MAbD3/

My workaround is to transition max-height to the exact content height for a nice smooth animation, then use a transitionEnd callback to set max-height to 9999px so the content can resize freely.

于 2012-03-19T00:12:34.397 に答える