A Pen by Ives van Hoorne on CodePen.
Created
August 15, 2017 10:04
-
-
Save CodeMyUI/3cd0898aec7cca1bb8dc676afcd75396 to your computer and use it in GitHub Desktop.
3D Cube Loading Animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="cube"> | |
<div class="sides"> | |
<div class="top"></div> | |
<div class="right"></div> | |
<div class="bottom"></div> | |
<div class="left"></div> | |
<div class="front"></div> | |
<div class="back"></div> | |
</div> | |
</div> | |
<div class="text">BUNDLING DEPENDENCIES</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css?family=Roboto:700'); | |
$size: 150px; | |
body { | |
font-family: 'Roboto', sans-serif; | |
background-color: #FFD399; | |
} | |
.container { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
flex-direction: row; | |
margin: 0 auto; | |
width: 50%; | |
} | |
@keyframes rotate { | |
0% { | |
transform: rotateX(-37.5deg) rotateY(45deg); | |
} | |
50% { | |
transform: rotateX(-37.5deg) rotateY(405deg); | |
} | |
100% { | |
transform: rotateX(-37.5deg) rotateY(405deg); | |
} | |
} | |
.cube, .cube * { | |
position: absolute; | |
width: $size + 1; | |
height: $size + 1; | |
} | |
.sides { | |
animation: rotate 3s ease infinite; | |
animation-delay: .8s; | |
transform-style: preserve-3d; | |
transform: rotateX(-37.5deg) rotateY(45deg); | |
} | |
.cube .sides * { | |
box-sizing: border-box; | |
background-color: rgba(242, 119, 119, .5); | |
border: $size / 10 solid white; | |
} | |
@mixin side($name, $rotate, $i) { | |
.#{$name} { | |
animation: #{$name}-animation 3s ease infinite; | |
animation-delay: $i * 100ms; | |
transform: #{$rotate} translateZ($size); | |
animation-fill-mode: forwards; | |
transform-origin: 50% 50%; | |
} | |
@keyframes #{$name}-animation { | |
0% { opacity: 1; transform: #{$rotate} translateZ($size)} | |
20% { opacity: 1; transform: #{$rotate} translateZ($size / 2)} | |
70% { opacity: 1; transform: #{$rotate} translateZ($size / 2) } | |
90% { opacity: 1; transform: #{$rotate} translateZ($size) } | |
100% { opacity: 1; transform: #{$rotate} translateZ($size) } | |
} | |
} | |
.cube .sides { | |
@include side("top", rotateX(90deg), 0); | |
@include side("bottom", rotateX(-90deg), 0); | |
@include side("front", rotateY(0deg), 1); | |
@include side("back", rotateY(-180deg), 1); | |
@include side("left", rotateY(-90deg), 1); | |
@include side("right", rotateY(90deg), 1); | |
} | |
.text { | |
margin-top: $size * 3; | |
color: rgba(242, 119, 119, 1); | |
font-size: 1.5rem; | |
width: 100%; | |
font-weight: 600; | |
text-align: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment