问题
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
来源:https://stackoverflow.com/questions/16150423/modernizr-check-for-grayscale-filters-ie-10