0%

大神们的惊人作品


本篇是我的第一百篇博客,分享一下之前收藏的大神们的优秀作品,从中学习

这个代码是我在逛知乎的时候,看到别人贴的代码

纯CSS实现,具有渐变倒影和3D旋转效果的栅栏动画,他的实现方式是:利用10个div元素创建10个栅条,接着再复制整份div元素,并创建一个渐变遮罩形成渐变效果,以此作为栅栏的倒影。

动态图

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
<div class="loader">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>

<div class="loader loader--reflect">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</div>

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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* Document defaults
*/
body {
text-align: center;
background-color: #eee;
}

* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}


/* The loader container */
.loader {
position: absolute;
top: 50%;
left: 50%;

width: 200px;
height: 100px;

margin-top: -100px;
margin-left: -100px;

perspective: 1000px;
transform-style: preserv3d;
}

.loader--reflect {
margin-top: 0;
}

.loader--reflect:after {
content: '';
position: absolute;
top: 0;
left: -25%;

width: 150%;
height: 110%;

background: linear-gradient(0deg, rgba(238, 238, 238, 1), rgba(238, 238, 238, 1) 20%, rgba(238, 238, 238, 0.3));
}


/* The bar */
.bar {
position: absolute;
bottom: 0;
left: 0;

width: 20px;
height: 100px;

background-color: #1e3f57;

transform: scaleY(0);
transform-style: preserve3d;

animation: bar 3s cubic-bezier(.81,.04,.4,.7) infinite;
}

.bar:nth-child(2) {
left: 20px;

background-color: #264a63;

animation-delay: 50ms;
}

.bar:nth-child(3) {
left: 40px;

background-color: #2d566f;

animation-delay: 100ms;
}

.bar:nth-child(4) {
left: 60px;

background-color: #35617a;

animation-delay: 150ms;
}

.bar:nth-child(5) {
left: 80px;

background-color: #3d6d86;

animation-delay: 200ms;
}

.bar:nth-child(6) {
left: 100px;

background-color: #447892;

animation-delay: 250ms;
}

.bar:nth-child(7) {
left: 120px;

background-color: #4c849e;

animation-delay: 300ms;
}

.bar:nth-child(8) {
left: 140px;

background-color: #548fa9;

animation-delay: 350ms;
}

.bar:nth-child(9) {
left: 160px;

background-color: #5c9bb5;

animation-delay: 400ms;
}

.bar:nth-child(10) {
left: 180px;

background-color: #63a6c1;

animation-delay: 450ms;
}

.loader--reflect .bar {
animation-name: bar-reflect;
}

@keyframes bar {
0% {
transform: rotateZ(-180deg) rotateX(-360deg);
}
75%,100% {
transform: rotateZ(0) rotateX(0);
}
}

@keyframes bar-reflect {
0% {
transform: rotateZ(180deg) rotateX(360deg);
}
75%,100% {
transform: rotateZ(0) rotateX(0);
}
}

git上还有许多纯css实现的神作,以后再继续分享

-------------本文结束感谢您的阅读-------------
没办法,总要恰饭的嘛~~