<div class="perspective">
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
</div>
body {
font-size: 100%;
}
.perspective {
background-color: hsla(0,0%,0%,.1);
background-image: -webkit-linear-gradient(hsla(0,0%,0%,.1) 2.5%, transparent 2.5%, transparent 97.5%, hsla(0,0%,0%,.1) 97.5%),
-webkit-linear-gradient(left, hsla(0,0%,0%,.1) 2.5%, transparent 2.5%, transparent 97.5%, hsla(0,0%,0%,.1) 97.5%);
background-size: 3em 3em;
box-shadow: 0 0 0 .1em hsla(0,0%,0%,.2);
height: 9em;
left: 50%;
margin: -7.5em;
padding: 3em;
position: absolute;
top: 50%;
width: 9em;
-webkit-transform: rotateX(45deg) rotateZ(45deg);
-webkit-transform-style: preserve-3d;
}
.cube,
.cube:after,
.cube:before {
box-shadow: inset 0 0 0 .25em hsla(0,0%,0%,.1);
content: '';
float: left;
height: 3em;
position: absolute;
width: 3em;
}
/* Top */
.cube {
background-color: #f66;
position: relative;
-webkit-transform: translateZ(3em);
-webkit-transform-style: preserve-3d;
-webkit-transition: .25s;
}
/* Left */
.cube:after {
background-color: #e55;
-webkit-transform: rotateX(-90deg) translateY(3em);
-webkit-transform-origin: 100% 100%;
}
/* Right */
.cube:before {
background-color: #d44;
-webkit-transform: rotateY(90deg) translateX(3em);
-webkit-transform-origin: 100% 0;
}
/* Alternate Colour */
.cube:nth-child(even) {
background-color: #fc6;
}
.cube:nth-child(even):after {
background-color: #eb5;
}
.cube:nth-child(even):before {
background-color: #da4;
}
/* Animation */
@-webkit-keyframes wave {
50% { -webkit-transform: translateZ(4.5em); }
}
.cube:nth-child(1) {
-webkit-animation: wave 2s .0s ease-in-out infinite;
}
.cube:nth-child(2) {
-webkit-animation: wave 2s .2s ease-in-out infinite;
}
.cube:nth-child(3) {
-webkit-animation: wave 2s .4s ease-in-out infinite;
}
.cube:nth-child(4) {
-webkit-animation: wave 2s 1.4s ease-in-out infinite;
}
.cube:nth-child(5) {
-webkit-animation: wave 2s 1.6s ease-in-out infinite;
}
.cube:nth-child(6) {
-webkit-animation: wave 2s .6s ease-in-out infinite;
}
.cube:nth-child(7) {
-webkit-animation: wave 2s 1.2s ease-in-out infinite;
}
.cube:nth-child(8) {
-webkit-animation: wave 2s 1.0s ease-in-out infinite;
}
.cube:nth-child(9) {
-webkit-animation: wave 2s .8s ease-in-out infinite;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.