写个登陆页面
时间: 2023-08-16 08:19:56 浏览: 69
好的,以下是一个简单的登陆页面的 HTML 和 CSS 代码示例:
HTML 代码:
```
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="login-box">
<h2>Login</h2>
<form>
<div class="user-box">
<input type="text" name="username" required="">
<label>Username</label>
</div>
<div class="user-box">
<input type="password" name="password" required="">
<label>Password</label>
</div>
<a href="#">
<span></span>
<span></span>
<span></span>
<span></span>
<input type="submit" value="Login">
</a>
</form>
</div>
</body>
</html>
```
CSS 代码:
```
@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
}
.login-box {
width: 360px;
background: #f2f2f2;
color: #000;
top: 50%;
left: 50%;
position: absolute;
transform: translate(-50%, -50%);
box-shadow: 0 5px 10px rgba(0,0,0,0.3);
padding: 70px 30px;
border-radius: 10px;
}
.login-box h2 {
margin: 0;
padding: 0 0 20px;
text-align: center;
font-size: 22px;
}
.login-box .user-box {
position: relative;
}
.login-box .user-box input {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #000;
margin-bottom: 30px;
border: none;
border-bottom: 1px solid #000;
outline: none;
background: transparent;
}
.login-box .user-box label {
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 16px;
color: #000;
pointer-events: none;
transition: 0.5s;
}
.login-box .user-box input:focus ~ label,
.login-box .user-box input:valid ~ label {
top: -20px;
left: 0;
color: #000;
font-size: 12px;
}
.login-box a {
position: relative;
display: inline-block;
padding: 10px 20px;
color: #000;
font-size: 16px;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
transition: 0.5s;
margin-top: 40px;
}
.login-box a:hover {
background: #000;
color: #fff;
border-radius: 5px;
box-shadow: 0 0 5px #000;
}
.login-box a span {
position: absolute;
display: block;
height: 100%;
width: 100%;
top: 0;
left: -100%;
z-index: -1;
background: linear-gradient(90deg, transparent, #000);
transition: 0.5s;
}
.login-box a:hover span {
left: 100%;
}
```
这段代码会生成一个带有输入框、标签和按钮的登录页面。当用户输入用户名和密码并点击“登录”按钮时,表单将被提交到服务器进行验证。