I am new to CSS but do know the basics, I want to trigger this animation by using a button. I cannot get it to work.
I used a couple of examples here in Stackoverflow, Jquery, Jscript, but none seem to refer to the @keyframes .
I see more about referring to an animation via classes and removing classes (As I understand this way to restart the animation by removing the element). I tried switching it to classes.
I also then wonder what is best practise?
What is the best way? I thought it would be simple, but I was mistaken.....
I have CSS like so:
#test { margin-left: 20px; margin-top: 20px; width: 50px; height: 0px; background: maroon; position: absolute; animation-name: example; animation-duration: 3s; animation-fill-mode: forwards; animation-delay: 0s; } @keyframes example { from { transform: translateY(200px)} to {height: 200px; background-color: teal;} }
divand thebutton? do you get any errors? all those factors come to play