1.视觉层次设计:
使用紫色渐变背景(#6366f1 → #a855f7)营造科技感
卡片容器采用磨砂玻璃效果(background: rgba(255, 255, 255, 0.95))
精致的投影(box-shadow)增强立体感
2.交互设计亮点:
悬停时卡片的抬升效果(transform: translateY)
输入框聚焦时的光晕动画(box-shadow过渡)
按钮的微动效(translateY和阴影变化)
图标颜色随输入状态改变
3.输入框设计:
使用Font Awesome图标增强可视化
创新的右侧图标布局
自动验证的HTML5输入类型(type="email")
输入框边框的颜色过渡动画
4.记住我组件:
自定义复选框样式(accent-color属性)
Flex布局实现完美对齐
流畅的忘记密码链接颜色过渡
5.社交登录模块:
使用伪元素创建分割线
社交图标的三维悬停效果
渐变的图标颜色过渡
包含Google、GitHub、微信三种登录方式
6.响应式设计:
容器宽度百分比+max-width组合
移动端适配的padding调整
自动适应的输入框宽度
媒体查询优化小屏幕显示
7.字体与排版:
使用Inter现代字体
科学的字号阶梯(1rem = 16px)
精细的字重控制(400/500/600)
合理的行高和间距设置
8.视觉增强细节:
卡片边角使用1.5rem大圆角
输入框采用0.75rem中等圆角
所有过渡动画时间保持0.3s一致性
阴影使用多层叠加营造深度
颜色过渡遵循主色(#6366f1)到辅色(#8b5cf6)的渐变
图标悬停时的三维位移效果
9.界面展示:
10.代码:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>现代风格登录界面</title>
<!-- 引入字体和图标库 -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
/* 基础重置 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
display: flex;
justify-content: center;
align-items: center;
font-family: 'Inter', sans-serif;
}
/* 登录容器 */
.login-box {
background: rgba(255, 255, 255, 0.95);
padding: 2.5rem;
border-radius: 1.5rem;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
width: 90%;
max-width: 400px;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-box:hover {
transform: translateY(-5px);
}
/* 标题样式 */
.title {
text-align: center;
margin-bottom: 2rem;
position: relative;
}
.title h1 {
color: #1f2937;
font-size: 1.8rem;
font-weight: 600;
margin-bottom: 0.5rem;
}
.title p {
color: #6b7280;
font-size: 0.9rem;
}
/* 输入框容器 */
.input-group {
margin-bottom: 1.5rem;
position: relative;
}
/* 输入框样式 */
.input-field {
width: 100%;
padding: 12px 40px 12px 15px;
border: 2px solid #e5e7eb;
border-radius: 0.75rem;
font-size: 1rem;
transition: all 0.3s ease;
}
.input-field:focus {
outline: none;
border-color: #6366f1;
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
/* 输入图标 */
.input-icon {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
color: #9ca3af;
transition: color 0.3s ease;
}
.input-field:focus ~ .input-icon {
color: #6366f1;
}
/* 记住我 & 忘记密码 */
.options {
display: flex;
justify-content: space-between;
align-items: center;
margin: 1.5rem 0;
font-size: 0.9rem;
}
.remember-me {
display: flex;
align-items: center;
gap: 0.5rem;
color: #6b7280;
}
.remember-me input {
accent-color: #6366f1;
}
.forgot-password {
color: #6366f1;
text-decoration: none;
font-weight: 500;
transition: color 0.3s ease;
}
.forgot-password:hover {
color: #7c3aed;
}
/* 登录按钮 */
.login-btn {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
color: white;
border: none;
border-radius: 0.75rem;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}
.login-btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}
/* 社交登录 */
.social-login {
margin-top: 2rem;
text-align: center;
}
.social-text {
color: #6b7280;
margin-bottom: 1rem;
position: relative;
}
.social-text::before,
.social-text::after {
content: '';
position: absolute;
top: 50%;
width: 45%;
height: 1px;
background: #e5e7eb;
}
.social-text::before {
left: 0;
}
.social-text::after {
right: 0;
}
.social-icons {
display: flex;
justify-content: center;
gap: 1.5rem;
}
.social-icon {
font-size: 1.4rem;
color: #6b7280;
transition: all 0.3s ease;
cursor: pointer;
}
.social-icon:hover {
color: #6366f1;
transform: translateY(-3px);
}
/* 响应式设计 */
@media (max-width: 480px) {
.login-box {
padding: 1.5rem;
}
.title h1 {
font-size: 1.5rem;
}
}
</style>
</head>
<body>
<div class="login-box">
<div class="title">
<h1>欢迎回来</h1>
<p>请登录您的账户</p>
</div>
<form>
<!-- 邮箱输入 -->
<div class="input-group">
<input type="email" class="input-field" placeholder="请输入邮箱" required>
<i class="fas fa-envelope input-icon"></i>
</div>
<!-- 密码输入 -->
<div class="input-group">
<input type="password" class="input-field" placeholder="请输入密码" required>
<i class="fas fa-lock input-icon"></i>
</div>
<!-- 选项 -->
<div class="options">
<label class="remember-me">
<input type="checkbox"> 记住我
</label>
<a href="#" class="forgot-password">忘记密码?</a>
</div>
<!-- 登录按钮 -->
<button type="submit" class="login-btn">立即登录</button>
<!-- 社交登录 -->
<div class="social-login">
<div class="social-text">其他方式登录</div>
<div class="social-icons">
<i class="fab fa-google social-icon"></i>
<i class="fab fa-github social-icon"></i>
<i class="fab fa-weixin social-icon"></i>
</div>
</div>
</form>
</div>
</body>
</html>