Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Transitions - Adding 2 different transitions to the same element

I am having issues with my CSS3 transitions:

div.one_fifth{
   border: 1px solid #48484A;
   transition : border 400ms ease-out; 
   -webkit-transition : border 400ms ease-out; 
   -moz-transition : border 400ms ease-out;
   -o-transition : border 400ms ease-out; 
   font-size: 18px;
   transition : font 300ms ease-out; 
   -webkit-transition : font 300ms ease-out; 
   -moz-transition : font 300ms ease-out;
   -o-transition : font 300ms ease-out;
}

 div.one_fifth:hover{
   border: 1px solid #ed2124;
   font-size: 20px;
 }

Now the problem is that when I define both the transitions, the border one does not work...So it seems like the two transitions interfere and the font one overrides the border one...How do I intergrate them, if so, how would you do it with different speeds(ms)?

like image 365
David Van Staden Avatar asked May 14 '13 14:05

David Van Staden


People also ask

How do you have multiple CSS transitions on an element?

You can transition two (or more) CSS properties by separating them with a comma in your transition or transition-property property. You can do the same with duration, timing-functions and delays as well. If the values are the same, you only need to specify one of them.

What is multi step animation?

That's the concept of multi-step animations in a nutshell: more than one change taking place in the animation from start to finish.


1 Answers

You can specify 2 or more comma-separated transitions, using a single transition property:

JSFiddle Demo

div.one_fifth {
    border: 1px solid #48484A;
    font-size: 18px;
    -webkit-transition : border 400ms ease-out, font 300ms ease-out; 
       -moz-transition : border 400ms ease-out, font 300ms ease-out;
         -o-transition : border 400ms ease-out, font 300ms ease-out; 
            transition : border 400ms ease-out, font 300ms ease-out; 
}
div.one_fifth:hover {
    border: 1px solid #ed2124;
    font-size: 20px;
}
like image 192
Matt Coughlin Avatar answered Sep 24 '22 12:09

Matt Coughlin