-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotateCube.html
139 lines (138 loc) · 2.98 KB
/
RotateCube.html
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
body {
-webkit-perspective: 800px;
perspective: 800px;
-webkit-perspective-origin: 50%;
perspective-origin: 50%;
}
.cube1 {
display: inline-block;
width: 100px;
height: 100px;
margin: 50px;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-animation: rotateY 5s linear 0s infinite;
animation: rotateY 5s linear 0s infinite;
}
.cube1 > div {
position: absolute;
width: 100%;
height: 100%;
box-shadow: inset 0 0 15px rgba(0, 255, 0, 0.5);
background-color: rgba(255, 255, 0, 0.3);
color: gray;
font-size: 20px;
line-height: 100px;
text-align: center;
}
.cube2 {
display: inline-block;
width: 100px;
height: 100px;
margin: 50px;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-animation: rotateZ 3s linear 0s infinite;
animation: rotateZ 3s linear 0s infinite;
}
.cube2 > div {
position: absolute;
width: 100%;
height: 100%;
box-shadow: inset 0 0 15px rgba(255, 0, 0, 0.5);
background-color: rgba(255, 0, 0, 0.2);
color: gray;
font-size: 20px;
line-height: 100px;
text-align: center;
}
#front {
-webkit-transform: translatez(50px);
transform: translatez(50px);
}
#back {
-webkit-transform: rotatey(180deg) translatez(50px);
transform: rotatey(180deg) translatez(50px);
}
#right {
-webkit-transform: rotatey(90deg) translatez(50px);
transform: rotatey(90deg) translatez(50px);
}
#left {
-webkit-transform: rotatey(-90deg) translatez(50px);
transform: rotatey(-90deg) translatez(50px);
}
#top {
-webkit-transform: rotatex(90deg) translatez(50px);
transform: rotatex(90deg) translatez(50px);
}
#bottom {
-webkit-transform: rotatex(-90deg) translatez(50px);
transform: rotatex(-90deg) translatez(50px);
}
@-webkit-keyframes rotateY {
from {
-webkit-transform: rotatey(0);
}
to {
-webkit-transform: rotatey(360deg);
}
}
@keyframes rotateY {
from {
transform: rotatey(0);
}
to {
transform: rotatey(360deg);
}
}
@-webkit-keyframes rotateZ {
from {
-webkit-transform: rotatez(0);
}
to {
-webkit-transform: rotatez(360deg);
}
}
@keyframes rotateZ {
from {
transform: rotatez(0);
}
to {
transform: rotatez(360deg);
}
}
.c1 > div {
-webkit-backface-visibility: visible;
backface-visibility: visible;
}
.c2 > div {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
</style>
</head>
<body>
<div class="cube1 c1">
<div id="front">1</div>
<div id="back">2</div>
<div id="right">3</div>
<div id="left">4</div>
<div id="top">5</div>
<div id="bottom">6</div>
</div>
<div class="cube2 c2">
<div id="front">A</div>
<div id="back">B</div>
<div id="right">C</div>
<div id="left">D</div>
<div id="top">E</div>
<div id="bottom">F</div>
</div>
</body>
</html>