JSFiddle - React, Tailwind, and code Playground
by LuckyCat
HTML
<div class="wrapper">
<div class="batman batman-1"></div>
<div class="batman batman-2"></div>
</div>
CSS
* {
margin: 0;
padding: 0;
}
html {
font-size: 62.5%;
}
html,
body {
height: 100%;
color: #fff;
}
body {
font-size: 1.8rem;
font-family: 'Neucha', cursive, Arial, sans-serif;
}
.wrapper {
position: relative;
text-align: center;
background: #333;
min-height: 400px;
height: 100%;
overflow: hidden;
}
@keyframes batmanFly {
0% {
}
25% {
}
50% {
}
100% {
top: 0;
left: 50%;
transform: translateX(-50%) rotate(3deg);
}
}
@keyframes fadeOut {
/*0% {opacity: 1;}*/
0% {opacity: 1;}
60%,100% {opacity: 0;}
/*0%,100% {opacity: 0;}*/
}
@keyframes fadeIn {
/*0%,40% {opacity: 0;}
100% {opacity: 1;}*/
/*0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: 1;}*/
0%,30% {opacity: 0;}
/*40% {opacity: 0;}*/
100% {opacity: 1;}
}
.batman {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
left: 140px;
top: 100%;
transform: translateY(-100%);
/*z-index: 11;*/
pointer-events: none;
}
.batman.flying {
/*animation-duration: 1s;*/
animation-fill-mode: forwards;
/*animation-name: batmanFly;*/
/*z-index: 25; */
}
.batman-1 {
background: green;
width: 62px;
height: 58px;
opacity: 1;
z-index: 21;
}
.batman-2 {
background: yellow;
width: 22px;
height: 78px;
opacity: 0;
border-radius: 15px;
box-shadow: 0 0 30px #000;
border: solid 7px #fff;
z-index: 22;
}
.batman.flying.batman-1 {
/*animation: fadeOut .5s ease 0s forwards;*/
animation-duration: 1s, 1s;
animation-name: batmanFly, fadeOut;
}
.batman.flying.batman-2 {
/*animation: fadeIn .5s ease .1s forwards;*/
animation-duration: 1s, 1s;
animation-name: batmanFly, fadeIn;
}
JavaScript
$(function() {
$(document).on('click touchstart', function(e) {
$('.batman').addClass('flying');
});
});