Skip to content

Instantly share code, notes, and snippets.

@matori
Created November 21, 2012 06:05
Show Gist options
  • Save matori/4123325 to your computer and use it in GitHub Desktop.
Save matori/4123325 to your computer and use it in GitHub Desktop.
[Modernizr] CSS transforms-style: preserve-3d;
Modernizr.addTest('csstransformspreserve3d', function () {
var prop,
val,
cssText,
ret;
prop = 'transform-style';
if ('webkitTransformStyle' in document.documentElement.style) {
prop = '-webkit-' + prop;
}
val = 'preserve-3d';
cssText = '#modernizr { ' + prop + ': ' + val + '; }';
Modernizr.testStyles(cssText, function (el, rule) {
ret = window.getComputedStyle ? getComputedStyle(el, null).getPropertyValue(prop) : '';
});
return (ret === val);
});
var test = Modernizr.csstransformspreserve3d;
console.log(test);
@mayloveless
Copy link

it won't work in Chrome 26 -,but i am not mean your code .

my problem here is:
when I use your code test Chrome 26- ,it showed it supported preserve-3d,so i wrote some css3 in the page.
However it couldn't do what preserve-3d shoud do,it won't keep 3d position. Chrome 29 did just fine.
plz help me with it. thx:)

@Grsmto
Copy link

Grsmto commented Sep 28, 2013

Works on Chrome 29/IE10. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment