网页设计登录页面代码
时间: 2024-06-17 19:06:51 浏览: 14
网页设计登录页面的代码可以分为 HTML、CSS 和 JavaScript 三个部分。
HTML 部分:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<link rel="stylesheet" href="login.css">
</head>
<body>
<div class="container">
<form class="login-form">
<h1>登录</h1>
<div class="form-group">
<label for="username">用户名:</label>
<input type="text" id="username" name="username">
</div>
<div class="form-group">
<label for="password">密码:</label>
<input type="password" id="password" name="password">
</div>
<div class="form-group">
<button type="submit">登录</button>
</div>
</form>
</div>
</body>
</html>
```
CSS 部分:
```
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
.container {
margin-top: 100px;
display: flex;
justify-content: center;
}
.login-form {
width: 400px;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
.login-form h1 {
text-align: center;
font-size: 28px;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type=text], input[type=password] {
width: 100%;
padding: 10px;
border-radius: 5px;
border: none;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
button[type=submit] {
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
}
```
JavaScript 部分:
```
// 可以在这里添加一些表单验证的逻辑
```