Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 transforms and transitions (Webkit)

Consider the following fiddle

p {   -webkit-transform: translate(-100%, 0);      -moz-transform: translate(-100%, 0);       -ms-transform: translate(-100%, 0);        -o-transform: translate(-100%, 0);           transform: translate(-100%, 0);   -webkit-transition: transform 1s ease-in;      -moz-transition: transform 1s ease-in;        -o-transition: transform 1s ease-in;           transition: transform 1s ease-in; }  a:hover + p {   -webkit-transform: translate(0, 0);      -moz-transform: translate(0, 0);       -ms-transform: translate(0, 0);        -o-transform: translate(0, 0);           transform: translate(0, 0); } 

The transition works smoothly in FF but there is no transition at all in Safari or Chrome (on my Mac).

Has the transition property to be prefixed or is there some kind of syntax error in my code?

like image 919
gregory Avatar asked Dec 08 '12 21:12

gregory


People also ask

What are CSS3 transitions and transform?

So what are transforms and transitions? At their most basic level, transforms move or change the appearance of an element, while transitions make the element smoothly and gradually change from one state to another.

What is WebKit transition CSS?

The -webkit-transition Boolean non-standardCSS media feature is a WebKit extension whose value is true if the browsing context supports CSS transitions. Apple has a description in Safari CSS Reference; this is now called transition there.

What is the difference between transition and transform CSS?

So, what's the difference between CSS Transform and CSS Transition? The Transform property in CSS moves or modifies the appearance of an element, whereas the Transition property seamlessly and gently transitions the element from one state to another.

What is the use of WebKit in CSS?

The term 'webkit' is used in the CSS syntax for rendering content in Safari and Chrome browsers. Webkit code may need to be added in CSS to ensure it renders correctly on Chrome and Safari due to the lack of cross-compatibility.


1 Answers

Add the vendor prefix in the transitions:

p {   -webkit-transform: translate(-100%, 0);      -moz-transform: translate(-100%, 0);       -ms-transform: translate(-100%, 0);        -o-transform: translate(-100%, 0);           transform: translate(-100%, 0);   -webkit-transition: -webkit-transform 1s ease-in; /* Changed here */       -moz-transition: -moz-transform 1s ease-in;        -o-transition: -o-transform 1s ease-in;           transition: transform 1s ease-in; }  a:hover + p {   -webkit-transform: translate(0, 0);      -moz-transform: translate(0, 0);       -ms-transform: translate(0, 0);        -o-transform: translate(0, 0);           transform: translate(0, 0); } 

Update (05/06/2014)

To answer some comments, the reason for omitting -ms-transition, is that it has never existed.

Check:

Can I Use? Transitions,

Can I Use? Transforms,

MDN transitions,

MDN transforms

like image 127
Fábio Duque Silva Avatar answered Oct 03 '22 01:10

Fábio Duque Silva