Just saw this CSS-only animation on http://csszengarden.com/219/, and wanted to recreate the animation, which starts when you hover over the middle card i.e.
Normally the site provides a CSS stylesheet, but on this example I couldn't find any.
The hover animation part was just an animation which first translated the y-axis and then changed the perspective.
My problem is that I don't really know how the unhover part of this animation is working because first the card has to keep the end state of the hoveranimation and then it first translate on the y-axis and then it zooms out so it's not a reversed animation of the hovering.
It tried the approach of keyframes with from and to. This approach could start the unhoveranimation with the right end state of the hover, but it only can handle a single animation and not animations which are sequential. Moreover with using from and to the animation just jumps when you unhover before the animation ended.
Here is what i've got so far.
.parent {
height: 1000px;
width: 1000px;
position: relative;
}
.child {
height: 40px;
width: 40px;
left: 40%;
border: medium solid black;
position: absolute;
}
.parent:hover .child{
animation: 3s in forwards;
}
@keyframes in {
50% {
transform: translate3d(0px, 100px, 0px);
}
100% {
transform: perspective(500px) translate3d(0px, 100px, 100px);
}
}
<div class="parent">
<div class="child"></div>
</div>