使用HTML+CSS实现毛玻璃登陆表单效果
阅读量:29
更新时间:2025-04-07 22:30:04
效果预览:效果预览
源码下载:关注公众号【程序员新视界】,回复【css19】可获取源码
HTML
html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>毛玻璃登录界面</title>
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<div class="glass">
<form class="login-form">
<h2>欢迎登录</h2>
<div class="input-group">
<input type="text" placeholder="用户名" required>
</div>
<div class="input-group">
<input type="password" placeholder="密码" required>
</div>
<button type="submit">立即登录</button>
<div class="links">
<a href="#">注册账号</a>
<a href="#">忘记密码?</a>
</div>
</form>
</div>
</body>
</html>
CSS
css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.glass {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-radius: 20px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px 0 rgba(52, 57, 120, 0.37);
padding: 40px;
width: 400px;
position: relative;
}
.login-form {
color: white;
}
h2 {
text-align: center;
margin-bottom: 30px;
font-size: 2em;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}
.input-group {
margin-bottom: 25px;
}
input {
width: 100%;
padding: 15px;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 8px;
color: white;
font-size: 16px;
transition: all 0.3s;
}
input:focus {
outline: none;
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.5);
}
input::placeholder {
color: rgba(255, 255, 255, 0.7);
}
button {
width: 100%;
padding: 15px;
background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
border: none;
border-radius: 8px;
color: white;
font-size: 16px;
cursor: pointer;
transition: all 0.3s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}
.links {
margin-top: 20px;
display: flex;
justify-content: space-between;
}
a {
color: rgba(255, 255, 255, 0.8);
text-decoration: none;
font-size: 14px;
}
a:hover {
color: white;
}