+ 7

Can I call a CSS animation onclick?

I want to make an animation that starts when you click a button, but I don't know if it's posible to use CSS animation or the only choice is creating the animation with Javascript, could you please help me?

5th Feb 2017, 3:44 PM
C.E.
C.E. - avatar
5 Respostas
+ 17
a:active { animation:…; } (try pseudo-events like : active,hover,visited,link……)
5th Feb 2017, 3:57 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 7
Thank you so much😊
5th Feb 2017, 3:57 PM
C.E.
C.E. - avatar
+ 5
Check this out They have explained it beautifully : http://stackoverflow.com/q/21919044/4166696
5th Feb 2017, 4:23 PM
N1nj@
N1nj@ - avatar
+ 3
You will need JavaScript yes, but only to modify the CSS code onclick. So, your onclick event will change the CSS code from what it is, to what you want it to be, thus creating the animation. It is however better to just animate using JQuery, a library of JavaScript.
5th Feb 2017, 3:56 PM
Andre van Rensburg
Andre van Rensburg - avatar
+ 3
You can avoid JS to perform an animation/transition between two state on a click, by using <input>s type checkbox/radio in combination with <label>s and/or <a>s links and their particular behaviours associated with css pseudo-classes ( look at properies/pseudo-classes 'checked', 'target' and so on... )
7th Feb 2017, 10:28 PM
visph
visph - avatar