I have a scenario where I need to immediately change the background colour on hover, and revert back immediately to the original colour on dehovering. This is simple enough with:
#el {
background-color: black;
}
#el:hover {
background-color: gray;
}
However, I'm having an issue where I also need to immediately change the background colour on active, but to use a transition when active is released.
#el:active {
background-color: green;
}
#el:hover:deactivate { /*does not exist*/
background-color: gray;
transition: background-color 1s ease;
}
#el:deactivate { /*does not exist either*/
background-color: black;
transition: background-color 1s ease;
}
I can't do this by setting #el:hover because then the hover entry also gets animated and I can't do this on #el itself because then dehovering also gets animated.
Is there any way to do this using pure CSS and without JS?