Created
August 20, 2012 01:23
-
-
Save Rob-ot/3399053 to your computer and use it in GitHub Desktop.
Detect which prefixed css calc to use via javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public domain, use it for whatever | |
// returns "calc", "-moz-calc", etc | |
// (no -ms because they already support it non-prefixed) | |
function prefixedCalc () { | |
var prefixes = ["","-webkit-","-moz-","-o-"], el | |
for (var i = 0; i < prefixes.length; i++) { | |
el = document.createElement('div') | |
el.style.cssText = "width:" + prefixes[i] + "calc(9px)" | |
if (el.style.length) return prefixes[i] + "calc" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment