-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcube.html
104 lines (100 loc) · 2.81 KB
/
cube.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
/*
rotateX 左右旋转
rotateY 上下旋转
rotateZ 角度旋转
perspective 拉伸 越小显示视角越大
透视距离太小,物体可能会被扭曲。如果太大,3D效果将减少到没有。著作权归作者所有。
translateZ的功能就是配合perspective让元素在自己的眼前或近或远
*/
#container{
margin: 0 auto;
width: 200px;
height: 200px;
transform-style: preserve-3d;
position: relative;
}
#font{
width: 200px;
height: 200px;
background-color: rebeccapurple;
opacity: .5;
border: 1px saddlebrown solid;
transform: translateZ(100px) ;
position: absolute;
top: 0;
left:0;
}
#back{
width: 200px;
height: 200px;
background-color: rebeccapurple;
opacity: .5;
border: 1px saddlebrown solid;
position: absolute;
top: 0;
left:0;
transform: translateZ(-100px);
}
#top{
width: 200px;
height: 200px;
background-color: rebeccapurple;
opacity: .5;
border: 1px saddlebrown solid;
position: absolute;
top: 0;
left:0;
transform: translateY(-100px) rotateX(90deg);
}
#bottom{
width: 200px;
height: 200px;
background-color: rebeccapurple;
opacity: .5;
border: 1px saddlebrown solid;
position: absolute;
top: 0;
left:0;
transform: translateY(100px) rotateX(90deg);
}
#left{
width: 200px;
height: 200px;
background-color: rebeccapurple;
opacity: .5;
border: 1px saddlebrown solid;
position: absolute;
top: 0;
left:0;
transform: translateX(-100px) rotateY(90deg);
}
#right{
width: 200px;
height: 200px;
background-color: rebeccapurple;
opacity: .5;
border: 1px saddlebrown solid;
position: absolute;
top: 0;
left:0;
transform: translateX(100px) rotateY(90deg);
}
</style>
</head>
<body style="display: flex;justify-content: center">
<div id="container">
<div id="font"></div>
<div id="back"></div>
<div id="top"></div>
<div id="bottom"></div>
<div id="left"></div>
<div id="right"></div>
</div>
</body>
</html>