I making a button with animated img on it. So when you hover on, car goes from left, and stops in center. And when you hover out - car goes to right. I've made a fiddle: https://jsfiddle.net/ufwyjd0o/
.button{
height:150px;
width: 150px;
background-color:#468189;
margin: 100px;
border-radius: 100%;
box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.6);
animation: size 1.5s infinite alternate;
position: relative;
}
@keyframes size {
0% {transform: scale(1.0);
box-shadow: 0px 3px 8px 0px rgba(0,0,0,0.6); }
100% {transform: scale(1.05);
box-shadow: 0px 8px 8px 0px rgba(0,0,0,0.4); }
}
.icon img{
height:75px;
width:auto;
position: absolute;
top: 40px;
animation: driveout 1s cubic-bezier(.52,.02,.31,.99) both;
transform: 1s;
}
@keyframes drive {
0% {transform: translate3d(-60px,0,0)}
5% {transform: translate3d(60px,0,0)}
10% {transform: translate3d(40px,0,0);}
}
@keyframes driveout {
0% {transform: translate3d(40px,0,0)}
100% {transform: translate3d(200px,0,0)}
}
.button:hover .icon img {
animation: drive 10s cubic-bezier(.52,.02,.31,.99) normal;
animation-play-state: pause;
display:block;
}