用html写一段登录注册的代码带有背景图片
时间: 2023-05-24 14:06:45 浏览: 222
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录注册</title>
<style>
body {
background-image: url("background.jpg");
background-size: cover;
}
.container {
margin: auto;
width: 50%;
padding: 10px;
background-color: white;
text-align: center;
}
input[type="text"],
input[type="password"] {
width: 70%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="submit"] {
width: 70%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.error {
color: red;
}
</style>
</head>
<body>
<div class="container">
<h2>登录</h2>
<form action="">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required><br>
<label for="password">密 码:</label>
<input type="password" id="password" name="password" required><br>
<input type="submit" value="登录">
</form>
<p class="error">用户名或密码错误!</p>
<h2>注册</h2>
<form action="">
<label for="new-username">新用户名:</label>
<input type="text" id="new-username" name="new-username" required><br>
<label for="new-password">新密码:</label>
<input type="password" id="new-password" name="new-password" required><br>
<input type="submit" value="注册">
</form>
<p class="error">该用户名已被注册!</p>
</div>
</body>
</html>
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)