Im trying to animate a button up to the center of it's parent element on hover using translateY and CSS3 animations, this seems to work fine (although any advice improvements would be great) but the problem is as soon as I hover off the button doesn't reverse the animation instead just resetting back to -50px. Was wondering how I can achieve this?
CSS (Using SCSS + Compass)
@include keyframe(slideIn) {
0%{
//opacity:0;
-webkit-transform:translateY(-50px);
}
60%{
//opacity:1;
//-webkit-transform:translateY(-195px);
}
80%{
-webkit-transform:translateY(-188px);
}
100%{
-webkit-transform:translateY(-175px);
}
}
.box {
width: 300px;
height: 300px;
background: navy;
position: relative;
-webkit-transform: translate3d(0, 0, 0);
overflow: hidden;
&:hover {
.btn {
@include animation(slideIn .45s ease-in-out alternate forwards);
}
}
}
.btn {
width: 50px;
height: 50px;
position: absolute;
bottom: -50px;
}
Codepen - http://codepen.io/styler/pen/fpFlL