Skip to content
Advertisement

CSS: make a property ignore the transition time without using jQuery

I recently got into this problem, I have a ‘div’ element that is set to have:

JavaScript

and when I add to this element the ‘toggled’ class it expand:

JavaScript

The problem here is that I want the opacity to go from a value of 0 to a value of 1 instantaneously, but since I have to set transition time to 1s this isn’t happening.

I saw a couple of solution to this problem but all of them use jQuery, which I’d prefer not to use.

I also tried this:

JavaScript

But nothing changed.

Advertisement

Answer

I just found a way to solve this:

JavaScript

Basically using the ‘transition-property’ property I tell on wich proprties the transition should have an effect.

Here’s a more in-depth explanation.

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