Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
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);'; = (str1 + prefixes.join(str2 + str1)).slice(0,-str1.length);
return (('' 'linear-gradient' ) !== -1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment