将一下代码放入js中:
function prefix() {
var div = document.createElement('div');
var cssText = '-webkit-transition:all .1s; -moz-transition:all .1s; -o-transition:all .1s; -ms-transition:all .1s; transition:all .1s;';
div.style.cssText = cssText;
var style = div.style;
if (style.webkitTransition) {
return '-webkit-';
}
if (style.MozTransition) {
return '-moz-';
}
if (style.oTransition) {
return '-o-';
}
if (style.msTransition) {
return '-ms-';
}
return '';
}
在需要的地方赋值,或直接调用:
var cssPrefix = prefix();
alert(cssPrefix);
代码出处:http://blog.csdn.net/qq_30100043/article/details/74719534
网友评论