JSFiddle - React, Tailwind, and code Playground
by cchana
HTML
<div class="item">
<div class="desktop">
</div>
<div class="mobile">
</div>
</div>
CSS
.item {
height: 400px;
width: 600px;
position: relative;
perspective: 1000px;
}
.desktop,
.mobile {
background-image: url('http://images.1thingaweek.com/heros/2017-reviewed.jpg');
background-size: cover;
background-position: center;
box-shadow: 0 5px 10px rgba(0,0,0,0.25);
}
/*.item:hover .desktop{
animation-name: desktop;
animation-duration: 1s;
animation-fill-mode: forwards;
}*/
.item:hover .mobile{
border: 2px solid #FFF;
animation-name: mobile;
animation-duration: 1.25s;
animation-fill-mode: forwards;
animation-timing-function: ease;
}
.item:hover .desktop {
animation-name: desktop;
animation-duration: 1s;
animation-timing-function: ease;
}
.desktop {
background-color: #800;
border-radius: 3px;
height: 200px;
width: 300px;
position: absolute;
left: 100px;
top: 100px;
z-index: 2;
}
.mobile {
background-color: #880;
border-radius: 3px;
height: 100px;
width: 60px;
position: absolute;
left: 300px;
top: 205px;
opacity: 0;
transition: opacity 0.5s;
}
@keyframes mobile {
0% {
top: 205px;
opacity: 0;
left: 325px;
z-index: 1;
}
50% {
left: 425px;
transform: rotateZ(3deg);
opacity: 1;
z-index: 1;
top: 205px;
}
100% {
opacity: 1;
left: 325px;
z-index: 3;
}
}
@keyframes desktop {
0% {
}
30% {
transform: rotate3D(1,-1,0.1,10deg) scale(1.05);
}
50% {
transform: rotate3D(1,-1,0.1,10deg) scale(1.05);
}
100% {
}
}
/*@keyframes desktop {
0% {
transform: rotateY(0) rotateZ(0);
}
100% {
transform: rotateY(3deg) rotateZ(3deg);
}
}*/