Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Apply hover out ease effect using css animation

Apply hover out ease effect using css animation

Problem

On this LIVE DEMO you can see how animation works in each div moves its image and gives opacity:1 to text.

When hover-off, naturally all styles get back to their initial state directly, but I want them to do it smoothly(ease), instead of setting all initial styles at the same time with no progress.

Here it is related animation code:

#highlights div[class*="high-"]:hover > p {
    -webkit-animation:downOp 0.3s ease-in 0s forwards;
    -ms-animation:downOp 0.3s ease-in 0s forwards;
    animation:downOp 0.3s ease-in 0s forwards;
}
#highlights div[class*="high-"]:hover > .image {
    -webkit-animation:imgTrans 5s ease-out 0s forwards;
    -ms-animation:imgTrans 5s ease-out 0s forwards;
    animation:imgTrans 5s ease-out 0s forwards;
}
@-webkit-keyframes downOp {
    0% {
        opacity:0.7;
    }
    100% {
        opacity:1;
    }
}
@-ms-keyframes downOp {
    0% {
        opacity:0.7;
    }
    100% {
        opacity:1;
    }
}
@keyframes downOp {
    0% {
        opacity:0.7;
    }
    100% {
        opacity:1;
    }
}
@-webkit-keyframes imgTrans {
    0% {
        margin-right: 0;
    }
    100% {
        margin-right: -50px;
    }
}
@-ms-keyframes imgTrans {
    0% {
        margin-right: 0;
    }
    100% {
        margin-right: -50px;
    }
}
@keyframes imgTrans {
    0% {
        margin-right: 0;
    }
    100% {
        margin-right: -50px;

} }

Problem courtesy of: Biomehanika

Solution

Use css transform instead of css animation! It will automatically handle hover-out effect!

  • See your fiddle here
  • See my modified effect jsfiddle

html


    

Rinoplastia
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod

css

    #highlights {
    min-height: 525px;
    width: 1170px;
    margin:0 auto;
}
#highlights div[class*="high-"] {
    border: 1px solid rgba(0, 0, 0, 0.28);
    display: inline-block;
    float: left;
    height: 150px;
    margin: 10px;
    position: relative;
    width: calc(33% - 20px);
    overflow: hidden;
}
#highlights .image {
    height:100%;
    transition:all 4s ease;
}
#highlights p {
    background-color: white;
    bottom: 0;
    height: 60px;
    margin-bottom: 0px;
    position: absolute;
    opacity:0.7;
    transition:all 0.6s ease;
}
#highlights span {
    display: block;
    font-size: 12px;
    margin: 2px;
}
#highlights:hover p {
    opacity:1;
}
#highlights:hover .image {
    transform:all 5s ease;
    margin-right: -50px;
}
#highlights .high-rinoplastia .image {
    background: url(http://mypet.guru/wp-content/uploads/2014/06/fluffy-cats-009.jpg) no-repeat right center;
}
#highlights .high-venas .image {
    background: url(http://mypet.guru/wp-content/uploads/2014/06/fluffy-cats-009.jpg) no-repeat right center;
}
#highlights .high-cirugiaCalvicie .image {
    background: url(http://mypet.guru/wp-content/uploads/2014/06/fluffy-cats-009.jpg) no-repeat right center;
}
#highlights .high-tratamientoCalvicie .image {
    background: url(http://mypet.guru/wp-content/uploads/2014/06/fluffy-cats-009.jpg) no-repeat right center;
}
Solution courtesy of: eirenaios

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Apply hover out ease effect using css animation

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×