请帮我写一个html+css带验证码的前端网页
时间: 2023-12-15 12:03:32 浏览: 26
好的,以下是一个简单的带验证码的前端网页示例,您可以参考一下:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>验证码登录</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
.container {
margin: auto;
width: 50%;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
#captcha {
margin-bottom: 10px;
}
img {
margin-right: 10px;
vertical-align: middle;
}
button[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
padding: 10px;
cursor: pointer;
}
button[type="submit"]:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<div class="container">
<h2>验证码登录</h2>
<form>
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<div id="captcha">
<label for="captcha_input">验证码:</label>
<input type="text" id="captcha_input" name="captcha_input" required>
<img src="captcha.php" alt="captcha">
</div>
<button type="submit">登录</button>
</form>
</div>
</body>
</html>
```
其中,`<img>` 标签的 `src` 属性指向了 `captcha.php` 文件,这个文件是用来生成并返回验证码图片的,您需要在后端编写这个文件。同时,您还需要编写一个用来验证验证码的逻辑。