hbuilder简单登录界面代码,需要输入验证码
时间: 2023-12-06 22:05:34 浏览: 36
以下是在上一个代码基础上加入验证码的简单登录界面代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
#login {
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
margin: 100px auto;
padding: 20px;
width: 300px;
}
#login h1 {
color: #333;
font-size: 24px;
margin-bottom: 20px;
text-align: center;
}
#login input[type="text"],
#login input[type="password"],
#login input[type="number"] {
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
display: block;
margin-bottom: 20px;
padding: 10px;
width: 100%;
}
#login button {
background-color: #4CAF50;
border: none;
border-radius: 3px;
color: #fff;
cursor: pointer;
display: block;
font-size: 16px;
margin: 0 auto;
padding: 10px;
width: 100%;
}
#login button:hover {
background-color: #3e8e41;
}
#login .code {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
#login .code input[type="text"] {
width: 60%;
}
#login .code img {
height: 40px;
}
</style>
</head>
<body>
<div id="login">
<h1>登录</h1>
<input type="text" placeholder="用户名">
<input type="password" placeholder="密码">
<div class="code">
<input type="text" placeholder="验证码">
<img src="https://dummyimage.com/120x40/000/fff&text=CODE" alt="验证码">
</div>
<button>登录</button>
</div>
</body>
</html>
```
在上述代码中,我们添加了一个新的`<div>`元素,包含一个用于输入验证码的文本框和一个随机生成的验证码图片。为了使验证码随机生成,我们使用了一个虚假的图片URL。在实际应用中,我们需要使用服务器端脚本来生成并返回真正的验证码图片。