0
Having an item, for example, an icon. I need your initial state to be gray and your CSS will be:
filter: grayscale(100%) opacity(0.5);
transition: 1s;
After that, in the :hover
the icon needs to increase, rotate and receive color:
filter: grayscale(0%) opacity(1);
transition-duration: 1s;
transform: scale(1.5) rotate(-15deg);
However, when removing the mouse you need to continue with the original color and size. Here’s what I already got, but when removing the mouse the icon needs to continue colored with its start size: watch video
"When removing the mouse you need to continue with the color" And you couldn’t start with that color? you want an element state control, something like "Hover at least once", and this kind of thing is not done with
css
, would have to do withjavascript
– Ricardo Pontual
I think you will need to use JS, because :Hover changes the properties of the element while the mouse is over it. When removing the mouse, it goes back to its original state.
– Sam
Only with CSS there is no way, because you can’t keep the state of Hover after taking the mouse from the elemeto. You can even go with one animation and come back with another. But keep the animation of the back after taking the mouse out you can’t
– hugocsl
Thank you so much for the feedback! And using JS? You would already have a base ready for me to understand how to do?
– Gabriel Marinho