✨ 用HTML和CSS实现登录界面

🎨 初音未来主题登录界面实现

✨ 效果预览

这是一个结合渐变背景与毛玻璃效果的现代化登录界面设计,采用初音未来作为视觉主题。

登录界面

🎯 核心特性

✨ 视觉设计

  • 渐渐变背景:135度渐变,从 #e0c3fc 到 #8ec5fc
  • 毛玻璃效果:使用 backdrop-filter: blur(10px)
  • 阴影层次:多层阴影增强立体感
  • 初音主题:左侧初音未来图片作为视觉焦点

📱 响应式特性

  • 相对单位(rem)确保缩放一致性
  • Flexbox 布局保证内容对齐
  • 适当的间距和内边距优化触摸操作

🎨 交互体验

  • 输入框聚焦效果
  • 按钮悬浮动效
  • 链接悬停反馈
  • 平滑过渡动画(transition)

🔧 实现思路详解

结构规划

  • 文字内容通过ht
  • 先设置一个登录界面的大盒子
  • 大盒子分为左右两边区域的内容,左边是图片,右边是登录区域
  • 左边图片区域较好实现。给右边区域设置一个盒子,这个盒子包括顶部,中部,底部
  • 右边区域的盒子,顶部,中部,底部可以再看成三个小盒子。通过flex布局,把三个盒子flex-direction: column竖直排列,再使用align-items: center居中对齐,使这三个小盒子在右边区域居中对齐。初步实现布局。
  • 最后通过对这三个小盒子的美化即可

关键技术点

Flexbox 布局:实现垂直居中和自适应排列
CSS 渐变:创建平滑的颜色过渡
伪元素应用:::before 实现背景层
现代 CSS 属性:backdrop-filter 实现毛玻璃效果

样式优化技巧

单位选择:使用 rem 保证响应式缩放
颜色透明:rgba() 控制透明度实现层次感
过渡动画:所有交互元素添加 transition
阴影运用:多层阴影增强立体效果

📝 注意事项

⚠️ 重要提示:这是一个纯前端展示作品,实际登录功能需要:

  • 后端服务器验证
  • 数据库用户信息存储
  • 安全传输(HTTPS)
  • 密码加密处理

🔗 扩展建议

1.添加功能:

  • 记住密码选项
  • 第三方登录(GitHub、Google等)
  • 验证码支持

优化方向:

  • 添加表单验证
  • 实现加载状态
  • 适配移动端

主题切换:

  • 夜间模式
  • 多主题支持
  • 自定义配色

💡 学习收获

通过这个项目,可以掌握:

  • 现代CSS布局技巧

  • 视觉层次设计原则

  • 交互细节优化

  • 响应式设计思路

    源码已完整提供,欢迎复制到本地运行体验!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录界面</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 10px;
}
html::before {
content: '';
width: 100%;
height: 100%;
position: fixed;
z-index: -1;
background: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%) no-repeat;
}
.box {
width: 70rem;
height: 40rem;
background-color: rgba(255, 255, 255, 30%);
margin: 10rem auto;
border-radius: 1.5rem;
border: 2px solid #000;
overflow: hidden;
display: flex;
box-shadow: 0 0 1rem 0.1rem;
}
/* 左侧区域 */
.box .left {
position: relative;
width: 35%;
height: 100%;
background-color: rgb(235, 135, 200);
opacity: 85%;
}
.box .left::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: url(/img/Miku01.jpg);
background-size: cover;
}
.box .right {
width: 65%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
background: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%) no-repeat;
}
.box .right form {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.box .right h3 {
font-size: 3rem;
color: rgb(124, 129, 241);
text-align: center;
line-height: 3rem;
width: 15rem;
height: 3rem;
margin-top: 3rem;
margin-bottom: 3rem;
cursor: default;
}
.box .right .input {
padding-top: 1rem;
padding-left: 1rem;
font-size: 2rem;
margin-top: 5%;
width: 60%;
height: 15%;
border: none;
outline: none;
border-bottom: 1px solid rgb(144, 129, 241);
background-color: rgba(0, 0, 0, 0);
}
.box .right .login {
margin-top: 4rem;
width: 30%;
height: 15%;
border: none;
font-size: 3rem;
color: rgb(144, 129, 241);
cursor: pointer;
background: linear-gradient(120deg, #e0c3fc 5%, #8ec5fc 100%);
}
.box .right .function {
display: flex;
justify-content: space-between;
width: 90%;
height: 10%;
font-size: 2rem;
margin-bottom: 1rem;
}
.box .right .function a {
text-decoration: none;
color: #6b7072;
}
.box .right .function a:hover {
color: rgb(234, 108, 108);
}
.box .right .login:hover {
color: rgb(245, 149, 162);
}
</style>
</head>

<body>
<div class="box">
<!-- 左侧区域 -->
<div class="left"></div>
<!-- 右侧区域 -->
<div class="right">
<h3>登录</h3>
<!-- 表单控件 -->
<form>
<input class="input" type="text" placeholder="用户名">
<input class="input" type="password" placeholder="密码">
<input class="login" type="submit" value="Login">
</form>
<!-- 功能区域 -->
<div class="function">
<a href="#">注册用户</a>
<a href="#">忘记密码</a>
</div>
</div>
</div>
</body>

</html>