I will leave this as an example of how to approach similar things when you have no alternative, but BoltClock's answer is the way to go in this case.
, , , getComputedStyle. , Supports custom props? true Chrome ( CSS), Supports custom props? false IE11 ( ):
function areCSSVarsSupported() {
var d = document.createElement('div');
d.id = "test";
document.body.appendChild(d);
var pos = getComputedStyle(d).position;
document.body.removeChild(d);
return pos === "fixed";
}
console.log("Supports custom props? " + areCSSVarsSupported());
:root{
--test-vars: fixed;
}
#test {
position: var(--test-vars);
}
Hide result