dice discover from MDN
by Outrora
HTML
<div class="box">
<div class="face front">1</div>
<div class="face back">2</div>
<div class="face right">3</div>
<div class="face left">4</div>
<div class="face top">5</div>
<div class="face bottom">6</div>
</div>
CSS
body {
/*perspective: 100px;*/
}
.box {
width: 100px;
height: 100px;
perspective: 550px;
transform-style: preserve-3d;
transition: all 0.3s;
}
.box:hover {
transform: rotate3d(1,1,0,180deg);
}
.face {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: absolute;
backface-visibility: inherit;
font-size: 60px;
color: #fff;
}
.front {
background: rgba(90,90,90,.7);
transform: translateZ(50px);
}
.back {
background: rgba(0,210,0,.7);
transform: rotateY(180deg) translateZ(50px);
}
.right {
background: rgba(200,100,0.7);
transform: rotateY(90deg) translateZ(50px);
}
.left {
background: rgba(200,0,0,.9);
transform: rotateY(90deg) translateZ(-50px);
}
.top {
background: rgba(0,0,0,.8);
transform: rotateX(90deg) translateZ(50px);
}