效果图
html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="box">
<form action="#" class="login-form">
<h2>登录</h2>
<input type="text" name="username" id="" placeholder="用户名">
<input type="text" name="password" id="" placeholder="密码 ">
<button type="submit">登录</button>
</form>
</div>
</body>
</html>
CSS代码
* {
margin: 0;
padding: 0;
}
.box {
display: flex;
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
background: url(https://coolbackgrounds.io/images/unsplash/josh-bean-medium-9501ba9f.jpg) no-repeat fixed;
background-size: cover;
}
.login-form {
display: flex;
position: relative;
width: 240px;
height: 220px;
flex-direction: column;
padding: 40px;
text-align: center;
z-index: 1;
background: inherit;
border-radius: 18px;
overflow: hidden;
}
.login-form::before {
content: '';
position: absolute;
top: -10px;
left: -10px;
width: calc(100% + 20px);
height: calc(100% + 20px);
background: inherit;
box-shadow: 0 0 0 200px rgba(255, 255, 255, .2) inset;
z-index: -1;
filter: blur(6px);
overflow: hidden;
}
.login-form h2 {
font-size: 18px;
font-weight: 400;
color: #3d5245;
}
.login-form input,
.login-form button {
margin: 6px 0;
height: 36px;
background-color: rgba(255, 255, 255, .3);
border: none;
border-radius: 4px;
padding: 0 14px;
color: #3d5245;
}
.login-form input::placeholder {
color: #3d5245;
}
.login-form button {
position: relative;
margin-top: 24px;
background-color: rgba(57, 88, 69, .4);
color: #ffffff;
overflow: hidden;
cursor: pointer;
transition: all 0.4s;
}
.login-form button:hover {
background-color: rgba(12, 88, 38, 0.67);
}
.login-form button::before,
.login-form button::after {
content: '';
display: block;
width: 80px;
height: 100%;
background-color: rgba(179, 255, 210, .5);
opacity: 0.5s;
position: absolute;
left: 0;
top: 0;
transform: skewX(-15deg);
filter: blur(30px);
overflow: hidden;
transform: translateX(-100px);
}
.login-form button::after {
width: 40px;
background-color: rgba(179, 255, 210, .3);
left: 60px;
filter: blur(5px);
opacity: 0;
}
.login-form button:hover::before {
transition: all 1s;
transform: translateX(320px);
opacity: 0.7;
}
.login-form button:hover::after {
transition: all 1s;
transform: translateX(320px);
opacity: 1;
}