Run css animation back and forth on clicks
问题 With css @keyframes I'm trying to attach some animation to an element when it is clicked. .animate { animation-name: action; animation-duration: 2s; animation-timing-function: linear; background-color: green; } @keyframes action { 0% { background-color: gray; } 50% { background-color: red; } 100% { background-color: green; } } DEMO The .animate class is added on click, and the box animates from gray to green. But now I would like to animate back to gray when I click it again (toggle