Perhaps you can use CSS3 Animations , using one for sliding and another for pulling:
@keyframes overlay-in { from { left: -999px; } to { left: 0; } } @keyframes overlay-out { from { left: 0; } to { left: 999px; } }
Now you can apply the overlay-in animation to :hover and the other to the normal element definition:
.box .overlay { /* other definitions ... */ animation-name: overlay-out; animation-duration: 1000ms; animation-fill-mode: none; } .box:hover .overlay { animation-name: overlay-in; animation-duration: 600ms; animation-fill-mode: forwards; }
But there is one problem: the slide animation will play once when the page loads. I cannot figure out how to prevent this without tiny JavaScript by adding a class to the overlay in the first mouseout event. I did it this way in JSFiddle .
But of course, as soon as you need JavaScript, you can also use simple transitions. But this method works even without JavaScript, if you can live with the animation that plays when the page loads.
Callidior
source share