forked from mt-bjtu-practical/Front-end-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
20211054-殷洪午.html
99 lines (99 loc) · 2.74 KB
/
20211054-殷洪午.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style>
/* CSS 样式 */
body {
background-image: url("http://5b0988e595225.cdn.sohucs.com/images/20190321/864b5c1779cf47389e6b137907d61bc3.jpeg");
background-repeat: no-repeat;
background-size: cover;
background-opacity: 0.8;
opacity: 0.6;
background-position: center center;
height: 90vh;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid #ccc;
border-radius: 5px;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
margin: 200px auto;
max-width: 600px;
padding: 20px;
justify-content: center;
align-items: center;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border: 1px solid #000;
box-sizing: border-box;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
box-sizing: border-box;
border: 1px solid #000; /* 设置边框为黑色 */
}
input[type="submit"] {
outline: 0;
border: none;
width: 100%;
background-color: #f93a0b;
padding: 0.938rem 1.5rem;
border-radius: 1.125rem;
font-weight: 400;
font-size: 1.4rem;
color: #fff;
font-weight: 700;
cursor: pointer;
border: 1px solid #000; /* 设置边框为黑色 */
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
.form-item {
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<form id="login-form">
<div class="form-item">
<label for="username"><strong>用户名<strong></label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-item">
<label for="password"><strong>密码<strong></label>
<input type="password" id="password" name="password" required>
</div>
<input type="submit" value="登录">
</form>
</div>
<script>
// JS 代码
const username = 'parrot5';
const password = '123456';
const form = document.getElementById('login-form');
form.addEventListener('submit', function(event) {
event.preventDefault();
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
if (usernameInput.value === username && passwordInput.value === password) {
alert('登录成功');
} else {
alert('用户名或密码错误');
}
});
</script>
</body>
</html>