var supports = (function() {
var div = document.createElement('div'),
vendors = 'Khtml Ms O Moz Webkit'.split(' '),
len = vendors.length;
return function(prop) {
if ( prop in div.style ) return true;
prop = prop.replace(/^[a-z]/, function(val) {
return val.toUpperCase();
});
while(len--) {
if ( vendors[len] + prop in div.style ) {
// browser supports box-shadow. Do what you need.
// Or use a bang (!) to test if the browser doesn't.
return true;
}
}
return false;
};
})();
if ( supports('textShadow') ) {
$('#support').html("Your browser supports textShadow property");
}
2 回答
没有必要2个不同的CSS文件 . 您可以使用modernizr与css检查浏览器是否支持css3动画并决定测试 .
如果不支持动画,你只需重新定位div .
将modernizr添加到页面
将class =“no-js”添加到html标记
如果浏览器不支持css动画,那么“no-cssanimations”将被添加到该类中
然后,您可以为不支持的浏览器添加自定义规则
检查使用相同技术的discussion
我认为这对你有用..
你可以用javascript做到这一点 . Source
这是工作小提琴:
http://jsfiddle.net/MehjK/