用js、css、HTML编写一个炫酷的登录界面
时间: 2024-01-24 07:04:27 浏览: 27
好的,下面我会给你提供一个简单的示例代码,实现一个炫酷的登录界面。
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>炫酷的登录界面</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="" required="">
<label>Username</label>
</div>
<div class="user-box">
<input type="password" name="" required="">
<label>Password</label>
</div>
<a href="#">
<span></span>
<span></span>
<span></span>
<span></span>
Submit
</a>
</form>
</div>
</body>
</html>
```
CSS代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #34495e;
}
.login-box {
width: 500px;
background: #191919;
padding: 40px;
border-radius: 10px;
box-shadow: 0 0 20px #00000080;
}
.login-box h2 {
color: #fff;
text-align: center;
margin-bottom: 30px;
}
.user-box {
position: relative;
}
.user-box input {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #fff;
margin-bottom: 30px;
border: none;
border-bottom: 1px solid #fff;
outline: none;
background: transparent;
}
.user-box label {
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 16px;
color: #fff;
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: #03a9f4;
padding: 10px 40px;
color: #fff;
font-size: 16px;
text-decoration: none;
border-radius: 30px;
position: relative;
overflow: hidden;
transition: .5s;
}
a:hover {
background: #fff;
color: #03a9f4;
}
a span {
position: absolute;
display: block;
}
a span:nth-child(1) {
top: 0;
left: -100%;
width: 100%;
height: 2px;
background: linear-gradient(90deg, transparent, #03a9f4);
animation: animate1 1s linear infinite;
}
@keyframes animate1 {
0% {
left: -100%;
}
50% {
left: 100%;
}
100% {
left: 100%;
}
}
a span:nth-child(2) {
top: -100%;
right: 0;
width: 2px;
height: 100%;
background: linear-gradient(180deg, transparent, #03a9f4);
animation: animate2 1s linear infinite;
animation-delay: .25s;
}
@keyframes animate2 {
0% {
top: -100%;
}
50% {
top: 100%;
}
100% {
top: 100%;
}
}
a span:nth-child(3) {
bottom: 0;
right: -100%;
width: 100%;
height: 2px;
background: linear-gradient(270deg, transparent, #03a9f4);
animation: animate3 1s linear infinite;
animation-delay: .5s;
}
@keyframes animate3 {
0% {
right: -100%;
}
50% {
right: 100%;
}
100% {
right: 100%;
}
}
a span:nth-child(4) {
bottom: -100%;
left: 0;
width: 2px;
height: 100%;
background: linear-gradient(360deg, transparent, #03a9f4);
animation: animate4 1s linear infinite;
animation-delay: .75s;
}
@keyframes animate4 {
0% {
bottom: -100%;
}
50% {
bottom: 100%;
}
100% {
bottom: 100%;
}
}
```
这个登录界面使用了CSS3的动画效果,通过伪元素和动画的组合实现了一个按钮的动态效果,非常炫酷。