I'm trying to achieve a rotating effect on a div when the cursor hovers over it, similar to what is shown in this video.
My preference is to utilize keyframes for this animation as they offer more customization options.
div.myElement {
...
animation: mainMenu 2s infinite;
animation-play-state: initial;
}
div.myElement:hover {
animation-play-state: running;
}
@keyframes mainMenu {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(45deg);
}
}
Despite implementing the code, I am facing difficulties with defining the necessary attributes for both div.myElement and div.myElement:hover. The transition seems to be from 0% to 100% for div.Element and from 100% back to 0% for div.Element:hover.