internet explorer 10 - how to apply grayscale filter?

前端 未结 3 1299
盖世英雄少女心
盖世英雄少女心 2020-11-27 03:35

This CSS code works pretty nice for Internet Explorer until 9.

img.gray {
    filter: url(\"data:image/svg+xml;utf8,

        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 04:05

    IE10 does not support DX filters as IE9 and earlier have done, nor does it support a prefixed version of the greyscale filter.

    However, you can use an SVG overlay in IE10 to accomplish the greyscaling. Example:

    img.grayscale:hover {
        filter: url("data:image/svg+xml;utf8,#grayscale");
    }
    
    svg {
        background:url(http://4.bp.blogspot.com/-IzPWLqY4gJ0/T01CPzNb1KI/AAAAAAAACgA/_8uyj68QhFE/s400/a2cf7051-5952-4b39-aca3-4481976cb242.jpg);
    }
    

    (from: http://www.karlhorky.com/2012/06/cross-browser-image-grayscale-with-css.html)

    Simplified JSFiddle: http://jsfiddle.net/KatieK/qhU7d/2/

    More about the IE10 SVG filter effects: http://blogs.msdn.com/b/ie/archive/2011/10/14/svg-filter-effects-in-ie10.aspx

提交回复
热议问题