写一个登录页面html
时间: 2023-06-12 19:04:09 浏览: 43
以下是一个简单的登录页面的HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 100px;
}
h2 {
margin-bottom: 30px;
}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.cancelbtn {
background-color: #f44336;
}
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 20%;
border-radius: 50%;
}
.container form {
border-radius: 5px;
background-color: #ffffff;
padding: 20px;
max-width: 400px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
span.psw {
float: right;
padding-top: 16px;
}
@media screen and (max-width: 600px) {
.container form {
width: 80%;
}
}
</style>
</head>
<body>
<div class="container">
<h2>Login Form</h2>
<form action="/action_page.php">
<div class="imgcontainer">
<img src="avatar.png" alt="Avatar" class="avatar">
</div>
<div>
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
</div>
<div>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
</div>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
<span class="psw"><a href="#">Forgot password?</a></span>
</form>
</div>
</body>
</html>
```
请注意,此代码仅包含HTML和CSS,没有任何JavaScript代码,因此无法实际验证登录。您需要将`action`属性指向您的后端代码以实现实际登录。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)