编写一个web登录界面啊
时间: 2023-06-13 18:07:23 浏览: 43
好的,我可以给你提供一个基本的示例代码,你可以根据自己的需求进行修改和优化。
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Web登录界面</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="login-box">
<h2>登录</h2>
<form>
<div class="user-box">
<input type="text" name="username" required="">
<label>用户名</label>
</div>
<div class="user-box">
<input type="password" name="password" required="">
<label>密码</label>
</div>
<a href="#">
<span></span>
<span></span>
<span></span>
<span></span>
<input type="submit" value="登录">
</a>
</form>
</div>
</body>
</html>
```
CSS代码:
```css
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background: linear-gradient(#141e30, #243b55);
}
.login-box{
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.login-box h2{
text-align: center;
margin-bottom: 50px;
}
.login-box form{
display: flex;
flex-direction: column;
}
.user-box{
position: relative;
margin: 25px 0;
}
.user-box input{
width: 100%;
padding: 10px 0;
font-size: 16px;
color: white;
border: none;
border-bottom: 1px solid white;
outline: none;
background: transparent;
}
.user-box label{
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 16px;
color: white;
pointer-events: none;
transition: .5s;
}
.user-box input:focus ~ label,
.user-box input:valid ~ label{
top: -20px;
left: 0;
color: #03a9f4;
font-size: 12px;
}
a{
display: inline-block;
background: transparent;
border: 2px solid white;
padding: 14px 40px;
color: white;
font-size: 16px;
text-transform: uppercase;
text-decoration: none;
transition: .5s;
position: relative;
}
a:hover{
background: white;
color: #03a9f4;
}
a span{
position: absolute;
display: block;
}
a span:nth-child(1){
top: 0;
left: -2px;
width: 2px;
height: 100%;
background: linear-gradient(#03a9f4, #03a9f4);
animation: animate1 1s linear infinite;
}
@keyframes animate1{
0%{
transform: scaleY(0);
}
50%{
transform: scaleY(1);
}
100%{
transform: scaleY(0);
}
}
a span:nth-child(2){
top: -2px;
left: 0;
width: 100%;
height: 2px;
background: linear-gradient(#03a9f4, #03a9f4);
animation: animate2 1s linear infinite;
animation-delay: .25s;
}
@keyframes animate2{
0%{
transform: scaleX(0);
}
50%{
transform: scaleX(1);
}
100%{
transform: scaleX(0);
}
}
a span:nth-child(3){
bottom: 0;
right: -2px;
width: 2px;
height: 100%;
background: linear-gradient(#03a9f4, #03a9f4);
animation: animate3 1s linear infinite;
animation-delay: .5s;
}
@keyframes animate3{
0%{
transform: scaleY(0);
}
50%{
transform: scaleY(1);
}
100%{
transform: scaleY(0);
}
}
a span:nth-child(4){
top: -2px;
right: 0;
width: 100%;
height: 2px;
background: linear-gradient(#03a9f4, #03a9f4);
animation: animate4 1s linear infinite;
animation-delay: .75s;
}
@keyframes animate4{
0%{
transform: scaleX(0);
}
50%{
transform: scaleX(1);
}
100%{
transform: scaleX(0);
}
}
```
这个示例代码实现了一个基本的登录界面,包括用户名和密码的输入框、登录按钮等。你可以根据自己的需求进行修改和优化,比如改变背景颜色、调整字体样式等。同时,你还需要编写后端代码来处理用户输入的信息和进行验证。