Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css Transitions one after another

I tried to make the CSS transitions to play one after other ,means first it has to transform the width and later height.
I tried with couple of options but everything is in vain.I achieved this in the javascript But can some CSSprofessionals help to explore this and break it up.Thanks in advance.

<style> 
div {
    width: 100px;
    height: 100px;
    background: red;
    -webkit-transition: width 2s;
    transition: all 2s;
}

div:hover {
    width: 300px;
    height:500px;
}
</style>
like image 783
Ankanna Avatar asked Mar 28 '16 19:03

Ankanna


People also ask

How do I put two transitions in CSS?

For multiple transitions, use the CSS3 transition property, which is a shorthand property. It sets the property, duration, timing, and delay of the transition in a single line.

How do you sequence an animation in CSS?

To create a CSS animation sequence, you style the element you want to animate with the animation property or its sub-properties. This lets you configure the timing, duration, and other details of how the animation sequence should progress.

How do I add a delay transition?

CSS Demo: transition-delayA value of 0s (or 0ms ) will begin the transition effect immediately. A positive value will delay the start of the transition effect for the given length of time. A negative value will begin the transition effect immediately, and partway through the effect.

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.


2 Answers

Break up the individual transition properties into comma-separated values for ease of reference....then just use transition delay to sequence them.

div {
    width: 100px;
    height: 100px;
    background: red;
    transition-property: width, height;
    transition-duration:2s, 4s;
    transition-delay:0s, 2s;
    transition-timing-function:linear;
}

div:hover {
    width: 300px;
    height: 300px;
 }
<div></div>
like image 79
Paulie_D Avatar answered Sep 27 '22 22:09

Paulie_D


Just use the transition-delay property in the transition shorthand to do multiple transitions in sequence in one CSS rule.

-webkit-transition: width 2s, height 2s ease 2s;
transition: width 2s, height 2s ease 2s;
like image 35
litel Avatar answered Sep 27 '22 20:09

litel