css3 - What is the right combination of prefixes for CSS transitions and transforms? -
what right way prefix css in order cover widest range of browsers , versions?
version 1:
-webkit-transition: -webkit-transform .3s ease-in-out; -moz-transition: -moz-transform .3s ease-in-out; -ms-transition: -ms-transform .3s ease-in-out; -o-transition: -o-transform .3s ease-in-out; transition: transform .3s ease-in-out; -webkit-transform: rotatex(-30deg); -moz-transform: rotatex(-30deg); -ms-transform: rotatex(-30deg); -o-transform: rotatex(-30deg); transform: rotatex(-30deg);
or version 2:
-webkit-transition: transform .3s ease-in-out; -moz-transition: transform .3s ease-in-out; -ms-transition: transform .3s ease-in-out; -o-transition: transform .3s ease-in-out; transition transform .3s ease-in-out; -webkit-transform: rotatex(-30deg); -moz-transform: rotatex(-30deg); -ms-transform: rotatex(-30deg); -o-transform: rotatex(-30deg); transform: rotatex(-30deg);
it appears me when using vendor prefixes on transition property, should target vendor prefixed attribute want transition.
i can't find closure this.
as mentioned in very similar question...
this 1 of cases vendor prefixes standardized features become extremely problematic, because need account different prefixed and/or unprefixed implementations of different features in different versions of different browsers.
what mouthful. , have combine various permutations of these. handful.
in short, need figure out versions of each browser requires prefix each of individual properties, , unless don't mind bloat, need apply prefixes differently individual browsers.
the linked question refers animations rather transitions results in different notations, both features went through similar unprefixing processes afaik. being said, here compatibility tables caniuse.com 2d transforms , transitions.
in other words, because 1 feature prefixed in 1 version of 1 browser doesn't mean other feature prefixed in same version of same browser. example, chrome unprefixed transitions @ least ten major versions (26) before unprefixed transforms (36), , safari still requires prefixes transforms. result, you're going have have declaration:
transition: -webkit-transform .3s ease-in-out;
and if absolutely need to, have cover older versions following:
-webkit-transition: -webkit-transform .3s ease-in-out;
other browsers, miraculously, able unprefix both transitions , transforms (as animations) simultaneously, makes things easier:
-ms-transition
used pre-release versions of ie10, have long since expired. no other version of ie uses prefixed transitions, should remove particular transition prefix.-ms-transform
prefix used ie9; ie10 , later ship unprefixed transforms. purposes of graceful degradation may want keep-ms-transform: rotatex(-30deg);
declaration — keep in mind cannot transitioned ie9 not support css transitions or animations.-moz-transition
,-moz-transform
used firefox , including 15, unprefixed in 16.-o-transition
,-o-transform
used opera , including 12.00, unprefixed in 12.10, re-prefixed-webkit-
in later versions in move blink.
in summary, here prefixes need, based on information given caniuse.com (which trust current , accurate part):
-webkit-transition: -webkit-transform .3s ease-in-out; /* chrome < 26, safari < 7 */ -moz-transition: -moz-transform .3s ease-in-out; /* firefox < 16 */ -o-transition: -o-transform .3s ease-in-out; /* opera < 12.10 */ transition: -webkit-transform .3s ease-in-out; /* chrome 26-35, safari, opera 15-23 */ transition: transform .3s ease-in-out; /* ie10+, firefox 16+, chrome 36+, opera 12.10 */ -webkit-transform: rotatex(-30deg); -moz-transform: rotatex(-30deg); -ms-transform: rotatex(-30deg); /* graceful degradation in ie9, cannot transitioned */ -o-transform: rotatex(-30deg); transform: rotatex(-30deg);
the bare minimum need support latest version of each browser of writing is:
transition: -webkit-transform .3s ease-in-out; /* chrome 26-35, safari, opera 15-23 */ transition: transform .3s ease-in-out; /* ie10+, firefox 16+, chrome 36+, opera 12.10 */ -webkit-transform: rotatex(-30deg); transform: rotatex(-30deg);
as mentioned in comments, can use tool autoprefixer automate based on level of browser support require. however, prefer write css manually, or wondering prefixes needed browsers, it.
on final note: notice 2 unprefixed transition
declarations in above examples? now, you'd think it'd easy enough combine them single declaration this:
transition: -webkit-transform .3s ease-in-out, transform .3s ease-in-out;
but, unfortunately, chrome erroneously ignore declaration, while other browsers apply fine.
Comments
Post a Comment