Skip to content
Advertisement

Css Transition does not work when is .myclass:not(.example) by clicking the button

I’d like to understand why some parameters work with transiton and some don’t. I have a button that brings up a div. If I only use max-height as a parameter then the transition works fine. When I insert other parameters such as opacity, top, etc… These only work on entry and never on closing. What am I doing wrong ?

You can see here that when you click the button for the first time, the transition works, when you click it the second time. the outbound transition does not work. The element disappear instantly.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

By setting multiple times “transition”, you’re overriding the previous one.

If you want multiple transitions, set it once with all your transitions separated with a comma:

JavaScript

Or use “all”:

JavaScript

More info: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement