Skip to content

Instantly share code, notes, and snippets.

@lylijincheng
Created August 9, 2013 10:44
Show Gist options
  • Save lylijincheng/6192732 to your computer and use it in GitHub Desktop.
Save lylijincheng/6192732 to your computer and use it in GitHub Desktop.
CSS style prefix.
var prefixStyle = function(style) {
var i, len, vendor, vendors, blank, camel;
vendors = ['', 'webkit', 'ms', 'Moz', 'O'];
blank = document.createElement('div').style;
camel = style.charAt(0).toUpperCase() + style.slice(1);
for (i = 0, len = vendors.length; i < len; i += 1) {
vendor = vendors[i] + camel;
if (vendor in blank) {
return vendor;
}
}
return style;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment