First, to show that it can be done.
Now that that's out of the way, let's get down to the nitty gritty and show you how to do it.
First, you'll want to use animation
to animate the properties and get the rotation effect. Sadly, a transition won't be enough since transitioning between 0 and 360 means you aren't going anywhere. So, animate your properties from one to the other on the hover. Your code will end up looking something like this:
@keyframes spin {
from { transform: scale(.1,.1) skew(0deg) rotate(0deg); }
to { transform: scale(1,1) skew(0deg) rotate(360deg); }
}
.myMsg:hover {
animation: spin 1s forwards;
}
The @keyframes
defines the animation that will happen, and you want to transform from one set of properties to the final one. Then, you set your :hover
to play that animation. The relevant properties for the animation are animation-name
, animation-duration
, and animation-fill-mode
(which say that it should have the same properties as the last frame when it is done animating. Webkit requires prefixes, so you'll want to put those in too.
In addition to this, I also placed a transition: transform 1s;
on the .myMsg
class so that it would animate back after the mouse moves away. But do note that Webkit doesn't seem to play nice with the interaction between the two, so it is a bit choppy and less than ideal. But, with experimental properties like this, sometimes you get what you get.
Some side notes:
- Your CSS isn't cross browser compatible, you should clean it up a bit
- You're defining 1 transform property, and then immediately overriding it. All transforms need to go in the same declaration. They can't be combined like that