测试 CSS "mix-blend-mode"
Testing of CSS "mix-blend-mode"
我想使用 CSS 的 属性 :
mix-blend-mode: soft-light;
我将通过 Modernizr 测试后备 bla bla...
已测试:
Modernizr.mixblendmode //undefined
Modernizr.testProp('mixblendmode'); //false
Modernizr.addTest('mixblendmode'); // no-mixblendmode
我错过了什么?
在 Firefox 上测试,CSS 它的工作,但是如何用 Modernizr 测试?
Modernizr 目前不支持此功能。来自 Modernizr/issues/1388:
Unfortunatly, "[...] in some browsers, mix-blend-mode is implemented; the property is valid, the automated tests pass, but no blending actually takes place" - http://blogs.adobe.com/webplatform/2013/09/12/browser-support-matrix-for-css-blending/
知道了:
Modernizr.addTest('mix-blend-mode', function(){
return Modernizr.testProp('mixBlendMode');
});
(或没有 Modernizr)
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/
我想使用 CSS 的 属性 :
mix-blend-mode: soft-light;
我将通过 Modernizr 测试后备 bla bla...
已测试:
Modernizr.mixblendmode //undefined
Modernizr.testProp('mixblendmode'); //false
Modernizr.addTest('mixblendmode'); // no-mixblendmode
我错过了什么?
在 Firefox 上测试,CSS 它的工作,但是如何用 Modernizr 测试?
Modernizr 目前不支持此功能。来自 Modernizr/issues/1388:
Unfortunatly, "[...] in some browsers, mix-blend-mode is implemented; the property is valid, the automated tests pass, but no blending actually takes place" - http://blogs.adobe.com/webplatform/2013/09/12/browser-support-matrix-for-css-blending/
知道了:
Modernizr.addTest('mix-blend-mode', function(){
return Modernizr.testProp('mixBlendMode');
});
(或没有 Modernizr)
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/