大家好,看到网上花花绿绿的网页旋转跳跃,自己也心动做了一个,长话短说,我们就来看一下吧。
先贴上代码和效果图。
HTML代码:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </ul>
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
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/* 给两个正方体设置旋转动画 */ @keyframes my3d { 0% { transform: rotateX(0) rotateY(0) rotateZ(0) } 100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg) } } ul { width: 200px; height: 200px; position: relative; perspective-origin: 50% 50%; transform-style: preserve-3d; margin: 200px auto; list-style: none; animation-name: my3d; animation-play-state: running; animation-duration: 10s; animation-iteration-count: infinite; } ul li { width: 200px; height: 200px; position: absolute; left: 0; top: 0; opacity: 0.7; } ul div { width: 100px; height: 100px; position: absolute; left: 50px; top: 50px; } /* 给里面的小正方体设置旋转 */ ul div:nth-last-child(6) { transform: rotateX(0deg) translateZ(50px); background-image: url("../images/1.png"); } ul div:nth-last-child(5) { transform: rotateX(90deg) translateZ(-50px); background-image: url("../images/2.png"); } ul div:nth-last-child(4) { transform: rotateX(0deg) translateZ(-50px); background-image: url("../images/3.png"); } ul div:nth-last-child(3) { transform: rotateX(-90deg) translateZ(-50px); background-image: url("../images/4.png"); } ul div:nth-last-child(2) { transform: rotateY(90deg) translateZ(-50px); background-image: url("../images/5.png"); } ul div:nth-last-child(1) { transform: rotateY(90deg) translateZ(50px); background-image: url("../images/6.png"); } /* 给外面的大正方体设置旋转 */ ul li:first-child { transform: rotateX(0deg) translateZ(100px); background-image: url("../images/1.png"); } ul li:nth-child(2) { transform: rotateX(90deg) translateZ(-100px); background-image: url("../images/2.png"); } ul li:nth-child(3) { transform: rotateX(0deg) translateZ(-100px); background-image: url("../images/3.png"); } ul li:nth-child(4) { transform: rotateX(-90deg) translateZ(-100px); background-image: url("../images/4.png"); } ul li:nth-child(5) { transform: rotateY(90deg) translateZ(-100px); background-image: url("../images/5.png"); } ul li:nth-child(6) { transform: rotateY(90deg) translateZ(100px); background-image: url("../images/6.png"); } /* 设置伪类hover鼠标碰触 */ ul:hover li:first-child { transition: 2s linear; transform: translateZ(200px); } ul:hover li:nth-child(3) { transition: 2s linear; transform: translateZ(-200px); } ul:hover li:nth-child(2) { transition: 2s linear; transform: rotateX(90deg) translateZ(-200px); } ul:hover li:nth-child(4) { transition: 2s linear; transform: rotateX(-90deg) translateZ(-200px); } ul:hover li:nth-child(5) { transition: 2s linear; transform: rotateY(90deg) translateZ(-200px); } ul:hover li:nth-child(6) { transition: 2s linear; transform: rotateY(90deg) translateZ(200px); } ul:hover div:nth-last-child(6) { transition: 3s linear; transform: translateZ(100px); } ul:hover div:nth-last-child(4) { transition: 3s linear; transform: translateZ(-100px); } ul:hover div:nth-last-child(5) { transition: 3s linear; transform: rotateX(90deg) translateZ(-100px); } ul:hover div:nth-last-child(3) { transition: 3s linear; transform: rotateX(-90deg) translateZ(-100px); } ul:hover div:nth-last-child(2) { transition: 3s linear; transform: rotateY(90deg) translateZ(-100px); } ul:hover div:last-child { transition: 3s linear; transform: rotateY(90deg) translateZ(100px); }
这两个分别是没有鼠标移入和鼠标移入时,一个嵌套在另一个的效果:
由于这两个正方体是不停的在旋转,所以观看的乐趣就在自己用代码实现后自己去细细品尝了。这个图形只用到了h5和除css3的知识,如有不理解,可以留下问题。可能代码写的有点累赘,希望不要嫌弃,嘻嘻。
最后
以上就是繁荣蜜粉最近收集整理的关于3D动画——正方体的旋转与张开的全部内容,更多相关3D动画——正方体内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复