Skip to content

Instantly share code, notes, and snippets.

@petersendidit
Created February 2, 2011 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save petersendidit/807683 to your computer and use it in GitHub Desktop.
Save petersendidit/807683 to your computer and use it in GitHub Desktop.
Modernizr test for linear-gradient() support
/*
Modernizr already has a test for cssgradients but it checks the old webkit syntax
In order to do px points we need linear-gradient()
Webkit did not have suport for linear-gradient() until Jan 2011
http://webkit.org/blog/1424/css3-gradients/
So here is a test to check for it.
*/
Modernizr.addTest('lineargradient', function () {
var test = document.createElement('div'),
prefixes = ' -webkit- -moz- -o- -ms- -khtml- '.split(' '),
str1 = 'background-image:',
str2 = 'linear-gradient(left top,#9f9, white);';
test.style.cssText = (str1 + prefixes.join(str2 + str1)).slice(0,-str1.length);
return ((''+test.style.backgroundImage).indexOf( 'linear-gradient' ) !== -1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment