Aessandro
Aessandro

Reputation: 5761

CSS delay transition

The following CSS works fine, however I am trying to add 1 or 2 seconds delay to the flip back effect. When you hover it the '.back' is visible and then when you leave the area the '.front'. I would like to add a delay so that when you leave the area it takes one or two seconds before it goes back to '.front' Is that possible?

.panel {
    width: 250px!important;
    height: 250px;
    margin: auto!important;
    position: relative;
    -webkit-perspective:1000px;
}

.card {
    width: 100%!important;
    height: 100%;
    -o-transition: all .5s;
    -ms-transition: all .5s;
    -moz-transition: all .5s;
    -webkit-transition: all .5s;
    transition: all .5s;
    -webkit-backface-visibility: hidden;
    -ms-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    position: absolute;
    top: 0px;
    left: 0px;
}

.front {
    z-index: 2;
}

.back {
    background-color:#fff;
    z-index: 1;
    -webkit-transform: rotateY(-180deg);
    -ms-transform: rotateY(-180deg);
    -moz-transform: rotateY(-180deg);  
    transform: rotateY(-180deg); 
    transition-delay: 2s; 
}

.back p{
    margin-top: 90px;
    font-size: 20px;
    text-align:center;
}

.panel:hover .front {
    z-index: 1;
    -webkit-transform: rotateY(180deg);
    -ms-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
    transform: rotateY(180deg);
     -webkit-transition:-webkit-transform 1s;
    transition:transform 1s;


}

.panel:hover .back {
    z-index: 2;   
    -webkit-transform: rotateY(0deg);
    -ms-transform: rotateY(0deg);
    -moz-transform: rotateY(0deg);
    transform: rotateY(0deg);
     -webkit-transition:-webkit-transform 1s;
    transition:transform 1s;
    transition-delay: 2s; 
}

HTML

<li class="panel"><a href="{{link}}"><img class="front card" src="{{image}}" /></a><div class="back card"><p>{{model.user.full_name}}</p></div></li>

Upvotes: 0

Views: 3273

Answers (2)

Adrift
Adrift

Reputation: 59769

Add the transition-delay to .card - fiddle

.card {
   -o-transition: all .5s 2s;
   -ms-transition: all .5s 2s;
   -moz-transition: all .5s 2s;
   -webkit-transition: all .5s 2s;
    transition: all .5s 2s;
}

Upvotes: 2

Octfx
Octfx

Reputation: 699

.panel .front {
  transition: all 2s;
}

You have to put the effect on the element in order to have it transition back without hovering on it.

Upvotes: 0

Related Questions