写一个关于垃圾分类管理的前端登录界面
时间: 2024-05-12 17:15:42 浏览: 11
好的,我可以为您提供一个简单的垃圾分类管理前端登录界面。以下是代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>垃圾分类管理系统</title>
<style>
body {
background-color: #f2f2f2;
}
h1 {
text-align: center;
margin-top: 50px;
}
form {
width: 30%;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}
label, input {
display: block;
margin-bottom: 10px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
.error {
color: red;
font-size: 14px;
margin-top: 10px;
}
</style>
</head>
<body>
<h1>垃圾分类管理系统</h1>
<form>
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="登录">
<div class="error" id="error"></div>
</form>
<script>
const form = document.querySelector('form');
const error = document.querySelector('#error');
form.addEventListener('submit', (e) => {
e.preventDefault();
const username = e.target.username.value;
const password = e.target.password.value;
if (username === 'admin' && password === '123456') {
window.location.href = './home.html';
} else {
error.textContent = '用户名或密码错误,请重新输入!';
}
});
</script>
</body>
</html>
```
以上代码会生成一个简单的登录界面,包括一个用户名和密码输入框、一个登录按钮和一个错误信息提示框。当用户输入正确的用户名和密码并点击登录按钮时,页面会跳转到 `home.html` 页面;如果输入错误则会在错误信息提示框中显示相应的错误信息。您可以根据实际需求进行修改和扩展。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)