Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Modernizr to test browser support for css calc()

How can I test if a browsers support the CSS3 calc() property using Modernizr?

I have tried:

if (Modernizr.testProp('cssCalc')) {
    console.log('CSS calc() supported');
}

but this only returns "undefined" in the console.

(I am using modernizr-2.6.2.js).

What is the right way to use Modernizr for browser feature detection?

like image 454
elizabethmeyer Avatar asked Aug 21 '13 13:08

elizabethmeyer


People also ask

How does modernizr detect browser?

We can access various properties of this object 'Modernizr' for feature detection using “Modernizr. featureName”. For example, Modernizr. video will return “true” if the browser supports the video element, and false if the browser doesn't.

What is modernizr how modernizr works?

Modernizr is a JavaScript library that detects the features available in a user's browser. This lets web pages avoid unsupported features by informing the user their browser isn't supported or loading a polyfill.

Which method checks whether the specific features get supported by the browser in node JS?

The idea behind feature detection is that you can run a test to determine whether a feature is supported in the current browser, and then conditionally run code to provide an acceptable experience both in browsers that do support the feature, and browsers that don't.


1 Answers

if (Modernizr.csscalc) {
  console.log('CSS calc() supported');
}
like image 172
SLaks Avatar answered Sep 24 '22 19:09

SLaks