# CSS3 人脸识别 扫描效果
# 涉及知识点
纯css 实现
- css3: background-image
- css3: animation 动画
- css3: clip-path使用 传送门 (opens new window)
- css: 伪类
<template>
<div class="demo-bg">
<div class="scan-area">
<div class="circle">
<div class="circle-inner">
<div class="circle-scan">
正在扫描...
</div>
</div>
<img src="/assets/images/head.gif?v=2" alt="face" />
</div>
<div class="scan-area-border"></div>
</div>
</div>
</template>
<style>
.vuepress-plugin-demo-block__app{
height:300px;
background:#090d2c;
background: #282537;
background-image: -webkit-radial-gradient(top, circle cover, #003399 0%, #252233 80%);
background-image: -moz-radial-gradient(top, circle cover, #003399 0%, #252233 80%);
background-image: -o-radial-gradient(top, circle cover, #003399 0%, #252233 80%);
background-image: radial-gradient(top, circle cover, #003399 0%, #252233 80%);
display:flex;
justify-content: center;
align-items:center;
}
.demo-bg:before{
content:'';
position:absolute;
left:0;
width:100%;
height:100%;
z-index:0;
}
.scan-area{
position:relative;
width: 240px;
height: 240px;
padding:20px;
}
.scan-area:before,
.scan-area:after,
.scan-area-border:before,
.scan-area-border:after{
content:'';
position:absolute;
width:40px;
height:40px;
border-style:solid;
border-color:#54d0e1;
}
.scan-area:before,
.scan-area:after{
top:0;
}
.scan-area:before{
left:0;
border-width:2px 0 0 2px;
}
.scan-area:after{
right:0;
border-width:2px 2px 0 0;
}
.scan-area-border:before,
.scan-area-border:after{
bottom:0;
}
.scan-area-border:before{
left:0;
border-width:0 0 2px 2px;
}
.scan-area-border:after{
right:0;
border-width:0 2px 2px 0;
}
.circle {
width:100%;
height:100%;
position: relative;
color:#62d7eb;
border: 1px solid #62d7eb;
/* box-shadow: inset 0 0 0 2px; */
border-radius: 50%;
z-index:1;
}
.circle::before,
.circle::after {
content: '';
z-index: 0;
margin: -5%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 2px solid #62d7eb;
/* box-shadow: inset 0 0 0 2px; */
border-radius: 50%;
animation: clipPath 20s linear infinite;
/* clip-path:polygon(0% 35%, 35% 35%, 35% 0%, 65% 0%, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0% 65%); */
clip-path: polygon(20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%);
}
.circle::before {
animation-delay: -2.74s;
}
@keyframes clipPath{
0%{}
50% {
transform: rotateZ(200deg);
}
100% {
transform: rotateZ(360deg);
}
}
@keyframes clipFade {
0%, 100% {
clip: rect(0px, 220.0px, 2px, 0px);
}
25% {
clip: rect(0px, 2px, 220.0px, 0px);
}
50% {
clip: rect(218.0px, 220.0px, 220.0px, 0px);
}
75% {
clip: rect(0px, 220.0px, 220.0px, 218.0px);
}
}
.circle-inner{
width:100%;
height:100%;
overflow: hidden;
border-radius: 50%;
position:absolute;
z-index:0;
background-size: 6px 6px;
background-image: -webkit-linear-gradient(top , transparent 5px, rgba(98,215,235,.6) 6px),
-webkit-linear-gradient(left, transparent 5px, rgba(98,215,235,.6) 6px);
}
.circle-scan{
position:absolute;
left:0;
width:100%;
height:100%;
animation: scanBeam 3s infinite;
animation-timing-function: linear;
animation-delay: 3s;
background-image: linear-gradient(180deg, rgba(95, 214, 249, 0) 50%, rgba(95, 214, 249, .9) 100%);
border-bottom:1px solid rgba(95, 214, 249);
text-align:center;
line-height:200px;
max-height:0%;
border-bottom-width:0;
}
.circle img{width:100%;border-radius: 50%;z-index:-2}
@keyframes scanBeam {
0%,60% {
border-bottom-width:0;
max-height:0%;
}
100% {
border-bottom-width:1px;
max-height:100%;
}
}
</style>
<script>
export default {}
</script>
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172