我想使用CSS的属性:
mix-blend-mode: soft-light;
我将通过 Modernizr 测试后备 bla bla...
测试:
Modernizr.mixblendmode //undefined
Modernizr.testProp('mixblendmode'); //false
Modernizr.addTest('mixblendmode'); // no-mixblendmode
我错过了什么?
在火狐浏览器上测试,CSS它的工作,但是如何使用Modernizr进行测试?
知道了:
Modernizr.addTest('mix-blend-mode', function(){
return Modernizr.testProp('mixBlendMode');
});
(或没有现代化)
if('CSS' in window && 'supports' in window.CSS) {
var support = window.CSS.supports('mix-blend-mode','multiply');
/* Add class like Modernizr */
/* -- jQuery -- */
$('html').addClass(support?'mix-blend-mode':'no-mix-blend-mode'); // jQuery
/* -- Pure JS -- */
document.getElementsByTagName('html')[0].className += support ? ' mix-blend-mode' : ' no-mix-blend-mode';
/* -- Pure JS (IE9+) -- */
document.querySelector('html').classList.add(support ? 'mix-blend-mode' : 'no-mix-blend-mode');
}
(或 CSS)
@supports(mix-blend-mode:multiply) {
}
编号 : https://dev.opera.com/articles/getting-to-know-css-blend-modes/
我可以使用 : http://caniuse.com/#feat=css-mixblendmode
Modernizr 目前不支持此功能。来自Modernizr/issues/1388:
不幸的是,"[...]在某些浏览器中,实现了混合混合模式;该属性有效,自动测试通过,但实际上没有发生混合" - http://blogs.adobe.com/webplatform/2013/09/12/browser-support-matrix-for-css-blending/