写一个网站登录注册页面代码
时间: 2024-05-01 17:20:29 浏览: 11
以下是一个简单的HTML和CSS代码示例,包含登录和注册表单:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login/Register Form</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<div class="form-container">
<form id="login-form">
<h2>Login</h2>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
<form id="register-form">
<h2>Register</h2>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Register</button>
</form>
</div>
</div>
</body>
</html>
```
CSS代码:
```css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-container {
background-color: white;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
padding: 30px;
}
form {
display: flex;
flex-direction: column;
}
form > h2 {
margin-bottom: 20px;
}
label {
margin-top: 10px;
}
input {
padding: 10px;
border-radius: 5px;
border: none;
margin-top: 5px;
margin-bottom: 20px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
}
button:hover {
background-color: #3e8e41;
}
```
该示例使用了flexbox布局来居中包含登录和注册表单的容器。每个表单都包含一些标签和输入字段,并有一个提交按钮。这只是一个基本示例,可以根据需要进行更改和扩展。