Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to turn an entire webpage to grayscale using CSS?

Tags:

I would like to turn an entire website to grayscale. Of course, I can manually edit the CSS and adjust every single color, background-color & co. property, and I can adjust every single image in Photoshop.

But is there an easier way, e.g. by using pure CSS?

E.g., something such as putting a 100% x 100% overlay div on top of your site that turns every color to grayscale?

Any hints?

like image 764
Golo Roden Avatar asked May 12 '15 13:05

Golo Roden


People also ask

How do I use grayscale in CSS?

CSS grayscale() FunctionThe grayscale() function in CSS is an inbuilt function that is used to apply a filter to the image to set the grayscale of the image. Parameters: This function accepts a single parameter amount that holds the value of grayscale. The value of grayscale is set in terms of number and percentage.

How do I convert an image to grayscale in CSS?

In webkit you do this: -webkit-filter: grayscale(100%); then this: -webkit-filter: grayscale(0); to remove it.

Which declaration will render an image completely grayscale?

contrast() A value of 0% will create an image that is completely gray.


2 Answers

No need to set the filter on every single element, You can apply the filter on HTML.

html {     -moz-filter: grayscale(100%);     -webkit-filter: grayscale(100%);     filter: gray; /* IE6-9 */     filter: grayscale(100%); } 

or body if you wish to keep a colored background on html.

http://codepen.io/anon/pen/VLawaK

like image 172
G-Cyrillus Avatar answered Oct 18 '22 10:10

G-Cyrillus


Yes there is, just use filter grayscale

CSS

*{     -moz-filter: grayscale(100%);     -webkit-filter: grayscale(100%);     filter: gray; /* IE6-9 */     filter: grayscale(100%); } 

Note: You can apply this in any element (html, body, header, etc...)

DEMO HERE

like image 25
Luís P. A. Avatar answered Oct 18 '22 10:10

Luís P. A.