CSS3 greyscale 滤镜实现
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="http://image.zhangxinxu.com/image/study/s/s256/mm1.jpg" />
<img src="http://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>
原文:http://www.zhangxinxu.com/wordpress/2012/08/%e5%b0%8ftip-%e4%bd%bf%e7%94%a8css%e5%b0%86%e5%9b%be%e7%89%87%e8%bd%ac%e6%8d%a2%e6%88%90%e9%bb%91%e7%99%bd%e7%9a%84/