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?
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.
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.
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.
if (Modernizr.csscalc) {
console.log('CSS calc() supported');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With