<!-- Cube by Dave DeSandro. Source: http://desandro.github.io/3dtransforms/docs/cube.html -->
<section class="container container-1">
<div class="cube">
<div class="front">1</div>
<div class="back">2</div>
<div class="right">3</div>
<div class="left">4</div>
<div class="top">5</div>
<div class="bottom">6</div>
<div class="z-plane">z=0 plane</div>
</div>
</section>
<section class="container container-2">
<div class="cube">
<div class="front">1</div>
<div class="back">2</div>
<div class="right">3</div>
<div class="left">4</div>
<div class="top">5</div>
<div class="bottom">6</div>
<div class="z-plane">z=0 plane</div>
</div>
</section>
<section class="container container-3">
<div class="cube">
<div class="front">1</div>
<div class="back">2</div>
<div class="right">3</div>
<div class="left">4</div>
<div class="top">5</div>
<div class="bottom">6</div>
<div class="z-plane">z=0 plane</div>
</div>
</section>
body {
background-color: #F5F5F5;
color: #555;
padding: 1em;
font-size: 1.1em;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
-webkit-perspective: 1000px;
}
.container {
width: 200px;
height: 200px;
margin: 100px;
position: relative;
display: inline-block;
-webkit-perspective-origin: 250% 250%;
perspective-origin: -150% -150%;
}
.container-2 {
-webkit-perspective: 800px;
perspective: 800px;
}
.container-1 {
-webkit-perspective: 200px;
perspective: 200px;
}
.container-3 {
-webkit-perspective: 1800px;
perspective: 1800px;
}
.cube {
width: 100%;
height: 100%;
position: absolute;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transform: translateZ(-100px);
transform: translateZ(-100px);
}
.cube div:not(:last-of-type) {
width: 196px;
height: 196px;
display: block;
position: absolute;
border: 2px solid black;
text-align: center;
color: white;
font-size: 25px;
line-height: 196px;
opacity: .9;
}
.cube .front {
background-color: deepPink;
-webkit-transform: rotateY( 0deg) translateZ( 100px);
transform: rotateY( 0deg) translateZ( 100px);
}
.cube .back {
background-color: #00eeaa;
-webkit-transform: rotateX( 180deg) translateZ( 100px);
transform: rotateX( 180deg) translateZ( 100px);
}
.cube .right {
background-color: purple;
-webkit-transform: rotateY( 90deg) translateZ( 100px);
transform: rotateY( 90deg) translateZ( 100px);
}
.cube .left {
background-color: #0099CC;
-webkit-transform: rotateY( -90deg) translateZ( 100px);
transform: rotateY( -90deg) translateZ( 100px);
}
.cube .top {
background-color: yellow;
-webkit-transform: rotateX( 90deg) translateZ( 100px);
transform: rotateX( 90deg) translateZ( 100px);
}
.cube .bottom {
background-color: orange;
-webkit-transform: rotateX( -90deg) translateZ( 100px);
transform: rotateX( -90deg) translateZ( 100px);
}
/* show the z=0 plane (for demonstration purposes) */
.z-plane {
background-color: white;
opacity: .4;
border: none;
color: grey;
width: 196px;
height: 196px;
display: block;
text-align: center;
line-height: 200px;
}