-
Notifications
You must be signed in to change notification settings - Fork 0
/
css3-rotate.html
116 lines (101 loc) · 2.23 KB
/
css3-rotate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container {
perspective: 1000px; /* 设置透视效果 */
transform-style: preserve-3d; /* 保持3D变换效果 */
position: relative;
height: 200px;
width: 200px;
margin: 100px auto;
animation: rotate 10s linear infinite; /* 旋转动画 */
}
.cube1, .cube2, .cube3 {
position: absolute;
width: 100px;
height: 100px;
top: 50%;
left: 50%;
transform-style: preserve-3d; /* 保持3D变换效果 */
}
.cube1 {
left: -200px;
transform: rotate3d(1, 1, 0, 45deg);
}
.cube2 {
left: 0;
transform: rotate3d(1, 0, 1, 45deg);
}
.cube3 {
left: 200px;
transform: rotate3d(0, 1, 1, 45deg);
}
.face1, .face2, .face3, .face4, .face5, .face6 {
position: absolute;
width: 100px;
height: 100px;
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid #ccc;
}
.face1 {
transform: translate3d(0, 0, 50px);
}
.face2 {
transform: rotateY(180deg) translate3d(0, 0, 50px);
}
.face3 {
transform: rotateY(-90deg) translate3d(0, 0, 50px);
}
.face4 {
transform: rotateY(90deg) translate3d(0, 0, 50px);
}
.face5 {
transform: rotateX(90deg) translate3d(0, 0, 50px);
}
.face6 {
transform: rotateX(-90deg) translate3d(0, 0, 50px);
}
@keyframes rotate {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(360deg);
}
}
</style>
</head>
<body>
<div class="container">
<div class="cube1">
<div class="face1"></div>
<div class="face2"></div>
<div class="face3"></div>
<div class="face4"></div>
<div class="face5"></div>
<div class="face6"></div>
</div>
<div class="cube2">
<div class="face1"></div>
<div class="face2"></div>
<div class="face3"></div>
<div class="face4"></div>
<div class="face5"></div>
<div class="face6"></div>
</div>
<div class="cube3">
<div class="face1"></div>
<div class="face2"></div>
<div class="face3"></div>
<div class="face4"></div>
<div class="face5"></div>
<div class="face6"></div>
</div>
</div>
</body>
</html>