Img hover css
Well, it depends on what you want to do.
First, there's the css filter property, which offers stuff like saturation, greyscale, contrast, etc and they are animatable. IE doesn't work though and might clash with the old proprietary IE filter property. You'll apply those filters overall and the only option I could think of in order to partially apply it would be to display the same image multile times stacked ontop and using the css mask property. That's pretty messy though.
The next option would be to not use the image within an <img> (old school and outdated) or <picture> (the modern way to go) tag but to apply it as a background image. That way you can simply switch out the image on :hover. However that is not animatable so it will be a hard transition.
Another option for a switch between images that is animatable is stacking the two images and setting opacity on :hover to 0. That can be easily animated.
With React (and other frameworks) you could also switch out the image when the cursor is on top of the object.
Pick your poison.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now