CSS3 animation can't be called by javascript -
i doing tests in order later animate website , want able make button bounce when clicked on cannot seem work. animation heading works fine on page load.
this entire code
<head> <script> function click(test){ test.style.webkitanimationname = 'bounce'; test.style.webkitanimationduration = '3s'; settimeout(function() { test.style.webkitanimationname = ''; }, 4000); } </script> <style> h1 { -webkit-animation-duration: 3s; -webkit-animation-name: slidein; } @-webkit-keyframes slidein { 0% { margin-left: 100%; width: 300%; } 100%{ margin-left: 0%; width: 100%; } } @-webkit-keyframes bounce { 0%, 20%, 50%, 80%, 100% { -webkit-transform: translatey(0); transform: translatey(0); } 40% { -webkit-transform: translatey(-30px); transform: translatey(-30px); } 60% { -webkit-transform: translatey(-15px); transform: translatey(-15px); } } </style> <title>success message</title> </head> <body> <h1> entered data required </h1> <button onclick="click(this)">amg4aeorg;ji</button> </body> can please tell me why isn't working, thank in advance
edit
ive done testing , found out the javascript function isn't running, know why? thx
make css class wrap animation, add css class name element.
test.setattribute('class','bouncethis'); css:
.bouncethis { -webkit-animation: bounce 3s ease-out; -moz-animation: bounce 3s ease-out; animation: bounce 3s ease-out; } @-webkit-keyframes bounce { ... etc.... }
Comments
Post a Comment