我想使用CSS的属性:
mix-blend-mode: soft-light;
我将通过 Modernizr 测试后备 bla bla...
Tested :
Modernizr.mixblendmode //undefined
Modernizr.testProp('mixblendmode'); //false
Modernizr.addTest('mixblendmode'); // no-mixblendmode
我缺少什么?
在 Firefox 上测试,CSS 可以工作,但是如何使用 Modernizr 进行测试?
Got it :
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');
}
(or CSS)
@supports(mix-blend-mode:multiply) {
}
Ref : https://dev.opera.com/articles/getting-to-know-css-blend-modes/ https://dev.opera.com/articles/getting-to-know-css-blend-modes/
我可以用吗 : http://caniuse.com/#feat=css-mixblendmode http://caniuse.com/#feat=css-mixblendmode
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)