15100218266 在线客服 人才招聘 返回顶部
企业动态 行业动态 技术分享

CSS怎么使网页全部变成灰色

2021-10-02 21:43:41 73 分享

Desaturating a color image couldn’t be simpler with CSS3. We’ll apply the filter as a class, as you’d typically desire several images to be affected by the code at the same time:

img.desaturate { filter: grayscale(100%); }

Naturally, all current browsers implement CSS3 filters via vendor prefixes, so our first job is to insert that code, writing in CSS that does not yet exist in order to future-proof our work:

img.desaturate { filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}

Applying the class to the image is easy:


Copyright © 2018-2020 追梦网络 All Rights Reserved. 冀ICP备14009401号-3