Grow your CSS skills. Land your dream job.

How Can i Trigger a CSS Animation With onclick?

  • # April 19, 2013 at 7:03 pm

    What is the simplest way to start a CSS animation when a button is clicked? maybe JavaScript?

    # April 19, 2013 at 7:21 pm

    Basically, you would set up two classes for the element. One initial and one active class. When you click the button, you would trigger the active class (with an addition of the active class to the element) which changes the attributes of the element using CSS. Take a look at this article for more help: http://www.impressivewebs.com/css3-transitions-javascript/. Also, I made this pen on CodePen: http://codepen.io/srig99/pen/KeswC.

    # April 20, 2013 at 6:04 am

    Create a class with a CSS animation. Apply/remove it with JavaScript.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".