<!-- Cube by Dave DeSandro. Source: http://desandro.github.io/3dtransforms/docs/cube.html -->
<section class="container">
<p><code>backface-visibility: visible;</code></p>
<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>
</section>
<section class="container">
<p><code>backface-visibility: hidden;</code></p>
<div class="cube cube-2">
<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>
</section>
body {
background-color: #F5F5F5;
color: #555;
font-size: 1.1em;
max-width: 900px;
margin: 0 auto;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
p {
margin-bottom: 6em;
}
.container {
width: 200px;
height: 200px;
margin: 50px 100px;
position: relative;
display: inline-block;
-webkit-perspective: 800px;
perspective: 800px;
-webkit-perspective-origin: 250% 250%;
perspective-origin: -150% -150%;
}
.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 {
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;
}
/* hide back face of faces in the second cube (on the right) */
.cube-2 div {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.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 );
}