Home  >  Article  >  Web Front-end  >  CSS设定图片变灰色_html/css_WEB-ITnose

CSS设定图片变灰色_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:37:471567browse


       在最近工作中,开发过程中需要设定一个图片变为灰色,刚开始我以为是更换图片,可是做了一段时间发现CSS就可以设定图片颜色变回灰色。具体的代码如下:

图片如下:


具体的实现由两种方法:一个是CSS3的滤镜功能。具体代码如下:

<span style="font-size:18px;">.gray {      -webkit-filter: grayscale(100%);     -moz-filter: grayscale(100%);     -ms-filter: grayscale(100%);     -o-filter: grayscale(100%);          filter: grayscale(100%); 	     filter: gray; }</span>

    只要把上面代码拷过去,设定成你想修改的图片样式就可以了。例如

<img  src="1.jpg" alt="CSS设定图片变灰色_html/css_WEB-ITnose" > <img  src="1.jpg" class="gray" alt="CSS设定图片变灰色_html/css_WEB-ITnose" >

  


版权声明:本文为博主原创文章,未经博主允许不得转载。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn