Using Modernizr to test browser support for css calc()
Asked Answered
L

1

7

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?

Lloyd answered 21/8, 2013 at 13:59 Comment(2)
testProp() takes a CSS property name.Damnify
Background on this: Safari 5 (which includes Safari for Windows and Mobile Safari running on IOS 5 doesn't support the CSS value calc() (see caniuse.com/calc). I want to use calc () in my CSS and js for a fallback for browsers that don't support this.Lloyd
D
10
if (Modernizr.csscalc) {
  console.log('CSS calc() supported');
}
Damnify answered 21/8, 2013 at 14:4 Comment(1)
I get undefined on all browsers. i am guessing modernizr does not include it in its default build?Collegian

© 2022 - 2024 — McMap. All rights reserved.