-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube.html
More file actions
113 lines (83 loc) · 2.61 KB
/
Copy pathcube.html
File metadata and controls
113 lines (83 loc) · 2.61 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: 0;
height: 100vh;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
overflow: hidden;
}
.container {
width: 100px;
height: 100px;
/* border: 2px solid black; */
position: relative;
/* perspective: 100px; */
transform-style: preserve-3d;
/* transform: rotateX(10deg) rotateY(30deg) scale3d(3, 3, 3); */
}
.face {
width: 100%;
height: 100%;
/* border: 1px solid green; */
position: absolute;
display: flex;
justify-content: center;
align-items: center;
color: white;
}
.face:nth-child(1) {
background-color: rgba(255, 0, 0, 0.445);
transform: translateZ(-50px);
}
.face:nth-child(2) {
background-color: rgba(255, 166, 0, 0.486);
transform: translateY(-50%) rotateX(90deg);
}
.face:nth-child(3) {
background-color: rgba(255, 255, 0, 0.473);
transform: translateZ(50px);
}
.face:nth-child(4) {
background-color: rgba(0, 128, 0, 0.534);
transform: translateY(50%) rotateX(90deg);
}
.face:nth-child(5) {
background-color: rgba(76, 0, 130, 0.377);
transform: translateX(-50%) rotateY(90deg);
}
.face:nth-child(6) {
background-color: rgba(238, 130, 238, 0.425);
transform: translateX(50%) rotateY(90deg);
}
</style>
</head>
<body>
<div class="container">
<div class="face">1</div>
<div class="face">2</div>
<div class="face">3</div>
<div class="face">4</div>
<div class="face">5</div>
<div class="face">6</div>
</div>
<script>
var container = document.getElementsByClassName('container')[0]
var ang = 0
animate()
function animate() {
container.style.transform = `rotateX(${ang}deg) rotateY(${ang + 45}deg)`
ang += 0.75
requestAnimationFrame(animate)
}
</script>
</body>
</html>