Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: how to turn an colour image to a grey or black/white image [duplicate]

Possible Duplicate:
Convert an image to grayscale in HTML/CSS

How can I turn an colour image to a grey or black/white image like this website with CSS?

Can it be done solely on CSS or do I need JavaScript (jQuery)?

Thanks.

Edit:

Thanks for the answers guys. I notice that the trick is to make two different colour images - one is full colour and the other is b/w. I was hoping this can be done in one single image. So there is no way to do that isn't apart from the 'trick'??

like image 654
Run Avatar asked May 13 '11 14:05

Run


2 Answers

To make it look really sweet id use jQuery and fade between the two check out this tutorial by Soh Tanaka. (I looks like this site did a variation of this tutorial.)

You can however do this with just css by creating an image sprite and changing the background position on :hover

like image 159
locrizak Avatar answered Sep 30 '22 14:09

locrizak


You can also try this jquery plugin greyScale

The effect can be done with one single image.

EDIT : I recommend also this Black and white jQuery plug in by Gianluca Guarini : This is easier to modify css.

like image 32
Sébastien Gicquel Avatar answered Sep 30 '22 13:09

Sébastien Gicquel