Im really stuck. I want the CSS animation that I created (below) to activate when I click on the div. The only way I could do this was to use javascript to create the onClick event. However, I don't know how to run the / refrence animation, which is in my css file. Can anybody help me?
This is the animation in my css file that I want to run by clicking on the div.
@-webkit-keyframes colorchange { 0% { background-color: red; opacity: 1.0; -webkit-transform: scale(1.0) rotate(0deg); } 33% { background-color: blue; opacity: 0.75; -webkit-transform: scale(1.1) rotate(-5deg); } 67% { background-color: green; opacity: 0.5; -webkit-transform: scale(1.1) rotate(5deg); } 100% { background-color: red; opacity: 1.0; -webkit-transform: scale(1.0) rotate(0deg); } }
I even tried putting css in the same file as javascript (index.html), and used the following code to try to activate it when clicked, but no luck.
<script> function colorchange( test ) { test.style.webkitAnimationName = 'colorchange '; } </script>
Please, help:)
javascript css
user531192
source share