The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

How Can i Trigger a CSS Animation With onclick?

  • Anonymous
    # 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

    This reply has been reported for inappropriate content.

    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: Also, I made this pen on CodePen:

    # 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.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed