Skip to content

Instantly share code, notes, and snippets.

@khalidmesbah
Created March 19, 2022 19:56
Show Gist options
  • Save khalidmesbah/69164578e92a6df9b39183cff8c0195f to your computer and use it in GitHub Desktop.
Save khalidmesbah/69164578e92a6df9b39183cff8c0195f to your computer and use it in GitHub Desktop.
91:Cube Loader
<div class="frame">
<div class="box">
<div class="side top"></div>
<div class="side bottom"></div>
<div class="side left"></div>
<div class="side right"></div>
<div class="side back"></div>
<div class="side front"></div>
<div class="side fill"></div>
</div>
</div>
.frame {
position: absolute;
inset: calc(50% - 200px);
border-radius: 2px;
box-shadow: 1px 2px 10px 0px rgba(0, 0, 0, 0.1);
overflow: hidden;
background: #34495e;
display: grid;
place-content: center;
perspective: 500px;
}
.box {
padding: 60px;
transform-style: preserve-3d;
transform: rotateX(-25deg) rotateY(45deg);
transition: all 500ms ease-in-out;
cursor: pointer;
&:hover {
transform: rotateX(-25deg) rotateY(45deg) translateY(-15px);
.bottom {
box-shadow: -22px -22px 30px 0 rgba(0, 0, 0, 0.4);
}
}
}
.side {
position: absolute;
inset: 0;
background-color: rgba(0, 0, 0, 0.1);
display: grid;
place-content: center;
&:not(.fill, .bottom, .top)::after {
position: absolute;
inset: 0;
content: "";
animation: fill 4s ease-in-out infinite alternate;
background-color: rgba(46, 204, 113, 0.8);
transform-origin: bottom center;
@keyframes fill {
0%,
25% {
transform: scaleY(0);
}
75%,
100% {
transform: scaleY(1);
}
}
}
}
.top {
transform: rotateX(90deg) translateZ(60px);
opacity: 0.5;
}
.bottom {
transform: rotateX(-90deg) translateZ(60px);
background: rgba(46, 204, 113, 0.8);
box-shadow: -8px -8px 10px 0 rgba(0, 0, 0, 0.4);
transition: all 500ms ease-in-out;
}
.left {
transform: rotatey(90deg) translateZ(60px);
}
.right {
transform: rotatey(90deg) translateZ(-60px);
}
.front {
transform: translateZ(60px);
}
.back {
transform: translateZ(-60px);
}
.fill {
background-color: rgba(46, 204, 113, 0.8);
animation: fill-top 4s ease-in-out infinite alternate;
@keyframes fill-top {
0%,
25% {
transform: rotateX(90deg) translateZ(-60px);
}
75%,
100% {
transform: rotateX(90deg) translateZ(59px);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment