CSS grayscale滤镜+SVG使图片变黑白实例页面
http:/CSS 地址:/www.runoob.com/cssref/css3-pr-filter.html
CSS代码: .gray { -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); filter: grayscale(100%); filter: url(gray.svg#grayscale); filter: gray; } HTML代码: <img src="//image.zhangxinxu.com/image/study/s/s256/mm1.jpg" /> <img src="//image.zhangxinxu.com/image/study/s/s256/mm1.jpg" class="gray" /> SVG代码: <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>
![](https://images2018.cnblogs.com/blog/1352355/201808/1352355-20180801153539236-1375290070.png)