internet explorer 10 - how to apply grayscale filter?

前端 未结 3 1300
盖世英雄少女心
盖世英雄少女心 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:01

    Inline SVG can be used in IE 10 and 11 and Edge 12.

    I've created a project called gray which includes a polyfill for these browsers. The polyfill switches out tags with inline SVG: https://github.com/karlhorky/gray

    To implement, the short version is to download the jQuery plugin at the GitHub link above and add after jQuery at the end of your body:

    
    

    Then every image with the class grayscale will appear as gray.

    
    

    You can see a demo too if you like.

提交回复
热议问题