请帮我写一个html+css带验证码的登录注册界面
时间: 2024-03-18 20:43:02 浏览: 21
好的,下面是一个简单的验证码登录注册界面的 HTML 和 CSS 代码:
HTML 代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login/Register</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="form">
<h2>Login/Register</h2>
<form action="#" method="post">
<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>
<label for="captcha">Captcha:</label>
<input type="text" id="captcha" name="captcha" required>
<img src="captcha.php" alt="Captcha">
<button type="submit" class="btn">Login</button>
<button type="submit" class="btn">Register</button>
</form>
</div>
</div>
</body>
</html>
```
CSS 代码:
```css
body {
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
.container {
width: 500px;
margin: 0 auto;
padding-top: 50px;
}
.form {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
display: block;
margin-bottom: 10px;
}
input {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
img {
display: block;
margin: 20px 0;
}
.btn {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
margin-bottom: 10px;
cursor: pointer;
}
.btn:hover {
background-color: #3e8e41;
}
```
这个界面包括了一个登录和注册表单,以及一个带验证码的输入框。验证码图片由 `captcha.php` 生成,这个文件需要自己编写,这里不做介绍。如果你需要更加详细的说明,可以参考这个教程:[How to Create a Simple PHP Captcha Script](https://www.codexworld.com/simple-php-captcha-script/)