密码输入框获取、失去焦点时,猫头鹰完成挡眼睛、放下的动作
效果预览:效果预览
源码下载:关注公众号【RMRF】,回复【css1】可获取源码
一、HTML
<!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>login</title>
<link rel="stylesheet" href="./css/index.css">
<script>
function onFucus() {
let owl = document.getElementById('owl')
owl.classList.add("owl-close")
}
function onBlur() {
let owl = document.getElementById('owl')
owl.classList.remove("owl-close")
}
</script>
</head>
<body>
<div class="login">
<div class="card">
<div id="owl" class="owl">
<div class="eyes"></div>
<div class="arm-up-right"></div>
<div class="arm-up-left"></div>
<div class="arm-down-left"></div>
<div class="arm-down-right"></div>
</div>
<div class="content">
<div class="item">
<img class="icon" src="./images/account.png" alt="">
<input type="text" placeholder="account">
</div>
<div class="item">
<img class="icon" src="./images/pwd.png" alt="">
<input type="password" placeholder="password" onfocus="onFucus()" onblur="onBlur()">
</div>
<div class="item">
<img class="icon" src="./images/code.png" alt="">
<input type="text" placeholder="code">
<img class="code" src="./images/number.png" alt="">
</div>
<div class="item">
<button>登陆</button>
</div>
</div>
</div>
</div>
</body>
</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
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
二、CSS样式
.login {
display: flex;
align-items: center;
justify-content: center;
height: 90vh;
}
.card {
position: relative;
padding: 30px;
width: 400px;
border-radius: 5px;
box-shadow: 0 0 6px #dddddd;
}
.content .item {
display: flex;
position: relative;
padding: 10px 0;
}
.content .icon {
position: absolute;
left: 8px;
top: 22px;
width: 20px;
height: 20px;
}
.content .code {
height: 40px;
}
.content input {
border-radius: 4px;
border: 1px solid #dcdfe6;
height: 40px;
outline: 0;
padding-left: 35px;
width: 100%;
}
.content input::input-placeholder {
color: #a8abb2 !important;
}
input::-webkit-input-placeholder {
color: #a8abb2;
}
input::-moz-placeholder {
color: #a8abb2;
}
input::-moz-placeholder {
color: #a8abb2;
}
input::-ms-input-placeholder {
color: #a8abb2;
}
.content button {
width: 100%;
border: 1px solid #dcdfe6;
border-radius: 4px;
cursor: pointer;
transition: 0.1s;
padding: 8px 15px;
color: #fff;
background-color: #409eff;
border-color: #409eff;
}
.content button:hover {
background-color: rgba(64, 160, 255, 0.7);
}
.content button:active {
background-color: rgba(64, 160, 255, 0.8);
}
.owl {
position: absolute;
top: -82px;
left: 50%;
width: 116px;
height: 92px;
background-size: 116px 92px;
margin-left: -64px;
cursor: pointer;
background-image: url(../images/face.png);
background-repeat: no-repeat;
background-size: 100% 100%;
}
.owl .eyes {
width: 100%;
height: 100%;
opacity: 0;
background-image: url(../images/eye.png);
background-repeat: no-repeat;
background-size: 100% 100%;
transition: 0.1s ease-out 0s;
}
.owl .arm-up-right {
width: 51px;
height: 41px;
position: absolute;
bottom: 10px;
right: 5px;
z-index: 2;
background-position: 0 25px;
opacity: 0;
background-image: url(../images/arm-up-right.png);
background-repeat: no-repeat;
background-size: 100% 100%;
transform: translateX(57px) scale(0.8);
transform-origin: 0 40px;
transition: background-position 0.3s ease-out,
transform 0.3s ease-out, opacity 0s linear 0.2s;
}
.owl .arm-up-left {
position: absolute;
bottom: 10px;
left: -3px;
width: 52px;
height: 41px;
z-index: 2;
background-position: 0 25px;
opacity: 0;
transform: translateX(-34px) scale(0.8);
transform-origin: 0 40px;
background-image: url(../images/arm-up-left.png);
background-repeat: no-repeat;
background-size: 100% 100%;
transition: background-position 0.3s ease-out,
transform 0.3s ease-out, opacity 0s linear 0.2s;
}
.owl .arm-down-left {
position: absolute;
bottom: 2px;
left: -34px;
width: 43px;
height: 25px;
z-index: 1;
transition: 0.3s ease-out;
background-image: url(../images/arm-down-left.png);
background-repeat: no-repeat;
background-size: 100% 100%;
}
.owl .arm-down-right {
position: absolute;
bottom: 1px;
right: -40px;
width: 43px;
height: 26px;
z-index: 1;
transition: 0.3s ease-out;
background-image: url(../images/arm-down-right.png);
background-repeat: no-repeat;
background-size: 100% 100%;
}
.owl-close .eyes {
opacity: 1;
transition: 0.1s ease-out 0.2s;
}
.owl-close .arm-up-right {
background-position: 0 0;
opacity: 1;
transform: scale(1);
transition: background-position 0.3s ease-out,
transform 0.3s ease-out;
}
.owl-close .arm-up-left {
transform: scale(1);
background-position: 0 0;
opacity: 1;
transition: background-position 0.3s ease-out,
transform 0.3s ease-out;
}
.owl-close .arm-down-left {
transform: translateX(40px) scale(0) translateY(-10px);
}
.owl-close .arm-down-right {
transform: translateX(-32px) scale(0) translateY(-8px);
}
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197