用css和html编写一个登录注册页面
时间: 2024-05-09 12:14:55 浏览: 13
好的,以下是一个简单的登录注册页面的代码示例:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login/Register Page</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
max-width: 400px;
margin: 0 auto;
}
input[type="text"], input[type="password"], input[type="email"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
h1 {
text-align: center;
}
.error {
color: #f00;
margin-bottom: 10px;
}
</style>
</head>
<body>
<form action="" method="POST">
<h1>Login</h1>
<div class="error"></div>
<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>
<input type="submit" value="Login">
</form>
<form action="" method="POST">
<h1>Register</h1>
<div class="error"></div>
<label for="fullname">Full Name:</label>
<input type="text" id="fullname" name="fullname" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<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>
<input type="submit" value="Register">
</form>
</body>
</html>
```
这段代码使用了 CSS 和 HTML 来创建一个简单的登录注册页面。其中,使用了 `<form>` 标签来创建表单,`<input>` 标签来创建输入框,`<label>` 标签来创建标签,以及一些 CSS 属性来设置样式。