I'm in the process of creating a stylish landing page using CSS3. One element that really stands out is an <a>
tag with a cool animation:
@keyframes splash {
from {
opacity: 0;
transform: scale(0, 0);
}
50% {
opacity: 1;
transform: scale(1.1, 1.1);
}
to {
transform: scale(1, 1);
}
To take it up a notch, I decided to add a hover effect as well:
@keyframes hover {
from {
transform: scale(1, 1);
}
to {
transform: scale(1.1, 1.1);
}
}
However, I encountered a problem when assigning these animations:
a {
/* Some basic styling applied here */
animation: splash 1s normal forwards ease-in-out;
}
a:hover {
animation: hover 1s infinite alternate ease-in-out;
}
Everything seems to work fine initially - the <a>
element splashes and vibrates on hover. But once the user moves away from the element, the smooth transition ends abruptly and the animation starts over. While this behavior makes sense, it's not what I want.
Is there a way to solve this issue without resorting to complex JavaScript tricks?