Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an Image turn Black and White on hover

Tags:

javascript

css

I have a linked image and I want to make it turn black and white when the user hovers on it. Can anyone help please? I need to make it either with CSS or JavaScript. Thanks

like image 667
user2302566 Avatar asked Apr 20 '13 16:04

user2302566


People also ask

How do you change color when hovering?

Changing link color on hover using CSS To change the color of your link on hover, use the :hover pseudo property on the link's class and give it a different color.

How do I make an image hover change?

Answer: Use the CSS background-image property You can simply use the CSS background-image property in combination with the :hover pseudo-class to replace or change the image on mouseover.


1 Answers

try this:

img.imgClass:hover {
    filter: url(filters.svg#grayscale); /* Firefox 3.5+ */
    filter: gray; /* IE5+ */
    -webkit-filter: grayscale(1); /* Webkit Nightlies & Chrome Canary */
}
img.imgClass {
    filter: none;
    -webkit-filter: grayscale(0);
}
like image 115
bbosternak Avatar answered Oct 26 '22 20:10

bbosternak