Start animation when hover - HTML CSS CSS

HTML CSS examples for CSS:Animation

Description

Start animation when hover

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
#revertMyAnimations {<!--from   w w w  . ja v  a2  s  . c  o m-->
   width:201px;
   height:201px;
   background-color:Chartreuse;
   -webkit-animation-fill-mode:backwards;
   animation-fill-mode:backwards;
   -webkit-animation-duration:0s;
   animation-duration:0s;
}

#revertMyAnimations:hover {
   background-color:yellow;
   -webkit-animation:bg 2s;
   -webkit-animation-fill-mode:forwards;
   animation:bg 2s;
   animation-fill-mode:forwards;
}

@-webkit-keyframes bg  {
   from {
      background-color:blue;
   }
   
   to {
      background-color:pink;
      margin-top:21px;
   }

}

@keyframes bg  {
   from {
      background-color:WhiteSmoke;
   }
   
   to {
      background-color:OrangeRed;
      margin-top:21px;
   }

}
</style> 
 </head> 
 <body> 
  <div id="revertMyAnimations"></div>  
 </body>
</html>

Related Tutorials