Code for the website to become gray

Source: Internet
Author: User

Filters are used in IE browser to solve the problem.

html{filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);}

 

Under chrome

-webkit-filter: grayscale(100%);

 

 

IE + Firefox + chrome

html {filter: grayscale(100%);-webkit-filter: grayscale(100%);-moz-filter: grayscale(100%);-ms-filter: grayscale(100%);-o-filter: grayscale(100%);filter: url(desaturate.svg#grayscale);filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter: grayscale(1);}

A large area of operations to reduce the page performance is certain. Here, I just want to share this article with you. Recently, I have seen this style, and it feels so amazing. In this style code, a file is involved, that isDesaturate. SVGFrom the file extension, we can see that the SVG technology is used. The Code is as follows:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg"> <filter id="grayscale"><fecolormatrix type="matrix" values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0  0  0  1 0"/> </filter> </svg>

You only need to save the codeDesaturate. SVGAnd then through the URL link, it is very simple. On the demo page we saw earlier, a style is added to the body, which affects all elements on the page. If necessary, you can set a class name in the public library to call the style. For example:

.pic_gray {filter: grayscale(100%);-webkit-filter: grayscale(100%);-moz-filter: grayscale(100%);-ms-filter: grayscale(100%);-o-filter: grayscale(100%);filter: url(desaturate.svg#grayscale);filter: gray;-webkit-filter: grayscale(1);}

  

 

  

 

 

Perfect compatibility, or simply add the following in CSS:

<style type="text/css">html{filter: grayscale(100%);-webkit-filter: grayscale(100%);-moz-filter: grayscale(100%);-ms-filter: grayscale(100%);-o-filter: grayscale(100%);filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter: grayscale(1);}</style>

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.