元素 height : auto 时,是不支持 CSS3 transition动画原因?

有css3高手可以从底层分析下吗?多谢

阅读 2.4k
1 个回答

这个在Using CSS transitions文档中有专门的解释:

The auto value is often a very complex case. The specification recommends not animating from and to auto. Some user agents, like those based on Gecko, implement this requirement and others, like those based on WebKit, are less strict. Using animations with auto may lead to unpredictable results, depending on the browser and its version, and should be avoided.

自动值通常是一个非常复杂的情况。 本规范建议不要为自动值设置动画。 一些用户代理比如基于Gecko的用户代理遵从了此规范,而其他用户代理比如基于WebKit的用户代理则不太严格。因为浏览器及其版本的不同,将动画与自动值一起使用可能会导致不可预测的结果,因此应避免使用。

如果一定想用,可以参考这篇文章里的方法。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题