/
cube.css
66 lines (56 loc) · 1.9 KB
/
cube.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* SOURCE :https://codepen.io/desandro/pen/KRWjzm */
* { box-sizing: border-box; }
body {
font-family: sans-serif;
}
/* .cube-cont {
width: 100%;
aspect-ratio: 1;
display: flex;
justify-content: center;
} */
.scene {
width: 95%;
aspect-ratio: 1;
border: 1px solid #CCC;
margin: 80px;
perspective: 1000px;
}
.cube {
width: 95%;
aspect-ratio: 1;
position: relaive;
transform-style: preserve-3d;
transform: translateZ(-100px);
transition: transform 1s;
}
.cube.show-front { transform: translateZ(-100px) rotateY( 0deg); }
.cube.show-right { transform: translateZ(-100px) rotateY( -90deg); }
.cube.show-back { transform: translateZ(-100px) rotateY(-180deg); }
.cube.show-left { transform: translateZ(-100px) rotateY( 90deg); }
.cube.show-top { transform: translateZ(-100px) rotateX( -90deg); }
.cube.show-bottom { transform: translateZ(-100px) rotateX( 90deg); }
.cube__face {
position: absolute;
width: 500px;
height: 500px;
border: 2px solid black;
line-height: 200px;
font-size: 40px;
font-weight: bold;
color: white;
text-align: center;
}
.cube__face--front { background: hsla( 0, 100%, 50%, 0.7); }
.cube__face--right { background: hsla( 60, 100%, 50%, 0.7); }
.cube__face--back { background: hsla(120, 100%, 50%, 0.7); }
.cube__face--left { background: hsla(180, 100%, 50%, 0.7); }
.cube__face--top { background: hsla(240, 100%, 50%, 0.7); }
.cube__face--bottom { background: hsla(300, 100%, 50%, 0.7); }
.cube__face--front { transform: rotateY( 0deg) translateZ(250px); }
.cube__face--right { transform: rotateY( 90deg) translateZ(250px); }
.cube__face--back { transform: rotateY(180deg) translateZ(250px); }
.cube__face--left { transform: rotateY(-90deg) translateZ(250px); }
.cube__face--top { transform: rotateX( 90deg) translateZ(250px); }
.cube__face--bottom { transform: rotateX(-90deg) translateZ(250px); }
label { margin-right: 10px; }