Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Transition not working

I couldn't get transitions to work on this page, anybody has any idea why?

div.sicon a {     transition: background 0.5s linear;     -moz-transition: background 0.5s linear; /* Firefox 4 */     -webkit-transition: background 0.5s linear; /* Safari and Chrome */     -o-transition: background 0.5s linear; /* Opera */     -ms-transition: background 0.5s linear; /* Explorer 10 */ } 
like image 712
Extelliqent Avatar asked Oct 28 '11 00:10

Extelliqent


People also ask

Why is transition not working in CSS?

If you have a transition not working, check that the starting value of the property is explicitly set. Sometimes, you'll want to animate height and width when the starting or finishing value is auto . (For example, to make a div collapse, when its height is auto and must stay that way.)

Why is transition property not working?

When we want to use transition for display:none to display:block, transition properties do not work. The reason for this is, display:none property is used for removing block and display:block property is used for displaying block. A block cannot be partly displayed. Either it is available or unavailable.

How do you add transition effects in CSS3?

To make the transition occur, you must specify at least two things — the name of the CSS property to which you want to apply the transition effect using the transition-property CSS property, and the duration of the transition effect (greater than 0) using the transition-duration CSS property.

Does transition work only on hover?

This will animate the color property when you hover over a link on the page. Pretty simple, and you've probably seen or used something similar. But transitions are not just limited to use with :hover . You can animate CSS properties, thus use CSS transitions without hover.


2 Answers

A general answer for a general question... Transitions can't animate properties that are auto. If you have a transition not working, check that the starting value of the property is explicitly set.

Sometimes, you'll want to animate height and width when the starting or finishing value is auto. (For example, to make a div collapse, when it's height is auto and must stay that way.) In this case, put the transition on max-height instead. Give max-height a sensible initial value (bigger than its actual height), then transition it to 0)

like image 187
bbsimonbb Avatar answered Sep 20 '22 20:09

bbsimonbb


For me, it was having display: none;

#spinner-success-text {     display: none;     transition: all 1s ease-in; }  #spinner-success-text.show {     display: block; } 

Removing it, and using opacity instead, fixed the issue.

#spinner-success-text {     opacity: 0;     transition: all 1s ease-in; }  #spinner-success-text.show {     opacity: 1; } 
like image 43
Abdrhmn Avatar answered Sep 23 '22 20:09

Abdrhmn