I have icons in my sidebar that start spinning on hover using an animation. When the user's mouse leaves the element, the animation stops quite abruptly. I'm trying to somehow make this transition more smooth.
Here's a simplified version of what I'm doing:
div {
font-size:18px;
line-height:32px;
width:32px;
height:32px;
background-color: yellow;
border-radius: 16px;
text-align: center;
}
div:hover {
animation: spin 2s;
}
@keyframes spin {
from{
transform: rotate(0deg);
}
to{
transform: rotate(360deg);
}
}
<p>Hover over the yellow circle below.</p>
<div>F</div>
Is there any way I can make the element either complete its iteration cycle, or otherwise ease out of its animation?