CSS transition with visibility not working

前端 未结 3 1442
面向向阳花
面向向阳花 2020-11-27 13:01

In the fiddle below, I\'ve a transition on visibility and opacity separately. The latter works but the former doesn\'t. Moreover, in case of visibility, the transition time

3条回答
  •  醉话见心
    2020-11-27 13:48

    This is not a bug- you can only transition on ordinal/calculable properties (an easy way of thinking of this is any property with a numeric start and end number value..though there are a few exceptions).

    This is because transitions work by calculating keyframes between two values, and producing an animation by extrapolating intermediate amounts.

    visibility in this case is a binary setting (visible/hidden), so once the transition duration elapses, the property simply switches state, you see this as a delay- but it can actually be seen as the final keyframe of the transition animation, with the intermediary keyframes not having been calculated (what constitutes the values between hidden/visible? Opacity? Dimension? As it is not explicit, they are not calculated).

    opacity is a value setting (0-1), so keyframes can be calculated across the duration provided.

    A list of transitionable (animatable) properties can be found here

提交回复
热议问题