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?

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
elizabethmeyer
  • 953
  • 2
  • 9
  • 13
  • `testProp()` takes a CSS _property name_. – SLaks Aug 21 '13 at 14:01
  • 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 http://caniuse.com/calc). I want to use calc () in my CSS and js for a fallback for browsers that don't support this. – elizabethmeyer Aug 22 '13 at 07:41

1 Answers1

10
if (Modernizr.csscalc) {
  console.log('CSS calc() supported');
}
Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • I get undefined on all browsers. i am guessing modernizr does not include it in its default build? – Anubhav Oct 27 '21 at 20:49