怎么写一个登录注册页面
时间: 2024-05-01 18:18:58 浏览: 9
一个登录注册页面通常包含以下几个元素:
1. 页面标题
2. 登录表单或注册表单
3. 输入框和标签(用户名、密码、确认密码、电子邮件等等)
4. 提交按钮
5. 注册链接或登录链接
6. 忘记密码链接
以下是一个基本的HTML和CSS的例子:
HTML:
```html
<!DOCTYPE html>
<html>
<head>
<title>登录/注册页面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>欢迎来到我们的网站</h1>
<h2>请登录或注册</h2>
<form id="login-form" action="login.php" method="post">
<h3>登录</h3>
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit">登录</button>
</form>
<form id="register-form" action="register.php" method="post">
<h3>注册</h3>
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="email">电子邮件</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<label for="confirm-password">确认密码</label>
<input type="password" id="confirm-password" name="confirm-password" required>
</div>
<button type="submit">注册</button>
</form>
</body>
</html>
```
CSS:
```css
h1, h2, h3 {
text-align: center;
}
form {
width: 50%;
margin: 0 auto;
}
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 5px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
}
button[type="submit"] {
display: block;
margin: 0 auto;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
background-color: #007bff;
color: #fff;
border: none;
}
button[type="submit"]:hover {
cursor: pointer;
background-color: #0069d9;
}
```
以上代码只是一个基础,你可以根据自己的需求进行更改和完善。