modernizr check for grayscale filters IE 10

匿名 (未验证) 提交于 2019-12-03 01:01:02

问题:

IE 10 does not support DX filters (yeaaaay) I'm currently using $.browser to detect IE 10 and implement the svg solution.

However the $.browser is deprecated and will be removed or is already removed (Yeaaaay again!!!!). So, what is modernizr's alternative for $.browser in this case?

filter: url("data:image/svg+xml;utf8,<svg 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>#grayscale"); /* Firefox 10+ */ filter: gray; /* IE6-9 */ -webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */ -webkit-transition: all .6s ease; /* Fade to color for Chrome and Safari */ -webkit-backface-visibility: hidden; /* Fix for transition flickering */ 

I tried if (Modernizr.css_filters) but that didn't work

回答1:

You should be able to use:

Modernizr.cssfilters 

or

Modernizr.svgfilters 

For targeting IE10 I think .svgfilters is the one you should be using. Here's a searchable database of Modernizr tests: http://www.browserleaks.com/modernizr#filter

These are the source files:

CSS Filter test: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/css/filters.js

SVG Filter test: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/filters.js



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!