Answers for "stop css animation on hover"

CSS
2

css start animation on hover

button{
  animation: rotate360 1.2s linear infinite;  /* animation set */
  animation-play-state: paused;               /* put paused */
}
button:hover{
  animation-play-state: running;              /* trigger on hover */
}
@keyframes rotate360 {                        /* keyframes of animation */
  to { transform: rotate(360deg); }           
}
Posted by: Guest on August-13-2020
0

animation not hover out

/* Add animation to normal selector as well, besides hover selector */
div {
  background-color: #333;
  transition: background-color 400ms;
} 

div:hover {
  background-color: #000;
  transition: background-color 400ms;
}
Posted by: Guest on January-08-2022

Browse Popular Code Answers by Language