1.色彩方案:
主色调采用柔和的#4a90e2(知更鸟蓝),搭配浅蓝背景渐变
辅助色使用#f0f9ff和#e6f4ff的渐变背景
文字颜色采用#666中性灰,保证可读性
2.视觉层次:
容器使用大圆角(20px)和柔和阴影创造卡片效果
通过backdrop-filter实现毛玻璃效果
进度指示器采用圆形数字标识+动态进度条
3.交互动画:
输入框聚焦时标签上移+颜色变化
步骤切换时的淡入淡出动画
完成时的对勾缩放动画
按钮的悬停效果和按压反馈
4.响应式设计:
容器最大宽度800px,适合各种屏幕
使用flex布局实现自适应排列
输入框宽度100%适配移动端
5.用户体验优化:
清晰的进度指示(4步流程)
即时视觉反馈(输入验证、按钮状态)
自然的过渡动画提升操作流畅感
6.代码结构:
语义化的HTML标签
CSS变量方便主题修改
模块化的JavaScript控制流程
详细的注释说明关键样式
7.截图展示:
8.代码重现:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>蓝天航空 - 机票预订</title>
<!-- 引入Material Icons字体图标 -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>
/* 基础重置与字体设置 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', '微软雅黑', sans-serif;
}
/* 整体页面渐变背景 */
body {
min-height: 100vh;
background: linear-gradient(135deg, #f0f9ff 0%, #e6f4ff 100%);
padding: 2rem;
}
/* 主容器样式 */
.container {
max-width: 800px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
backdrop-filter: blur(10px);
padding: 2rem;
}
/* 进度指示器样式 */
.progress-steps {
display: flex;
justify-content: space-between;
margin-bottom: 3rem;
position: relative;
}
.step {
width: 40px;
height: 40px;
border-radius: 50%;
background: #e0e0e0;
display: flex;
align-items: center;
justify-content: center;
color: white;
position: relative;
z-index: 2;
transition: all 0.3s ease;
}
.step.active {
background: #4a90e2;
transform: scale(1.1);
}
/* 进度条动画效果 */
.progress-bar {
position: absolute;
top: 50%;
left: 10%;
right: 10%;
height: 4px;
background: #e0e0e0;
transform: translateY(-50%);
}
.progress-fill {
height: 100%;
background: #4a90e2;
transition: width 0.3s ease;
}
/* 表单卡片样式 */
.form-card {
display: none;
opacity: 0;
transform: translateY(20px);
transition: all 0.3s ease;
}
.form-card.active {
display: block;
opacity: 1;
transform: translateY(0);
}
/* 输入框动态效果 */
.input-group {
margin-bottom: 1.5rem;
position: relative;
}
.input-group input, .input-group select {
width: 100%;
padding: 1rem;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 1rem;
transition: all 0.3s ease;
}
.input-group input:focus, .input-group select:focus {
outline: none;
border-color: #4a90e2;
box-shadow: 0 0 8px rgba(74, 144, 226, 0.2);
}
.input-group label {
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
background: white;
padding: 0 0.5rem;
color: #666;
transition: all 0.3s ease;
pointer-events: none;
}
.input-group input:focus ~ label,
.input-group input:valid ~ label {
top: 0;
font-size: 0.8rem;
color: #4a90e2;
}
/* 按钮样式 */
.btn-group {
display: flex;
justify-content: space-between;
margin-top: 2rem;
}
.btn {
padding: 0.8rem 2rem;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
transition: all 0.3s ease;
}
.btn-primary {
background: #4a90e2;
color: white;
}
.btn-primary:hover {
background: #357abd;
box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}
.btn-secondary {
background: #f0f0f0;
color: #666;
}
/* 完成动画 */
.success-animation {
text-align: center;
padding: 2rem;
}
.checkmark {
font-size: 4rem;
color: #4a90e2;
animation: scaleUp 0.5s ease;
}
@keyframes scaleUp {
0% { transform: scale(0); }
90% { transform: scale(1.1); }
100% { transform: scale(1); }
}
</style>
</head>
<body>
<div class="container">
<!-- 进度指示器 -->
<div class="progress-steps">
<div class="step active">1</div>
<div class="step">2</div>
<div class="step">3</div>
<div class="step">4</div>
<div class="progress-bar">
<div class="progress-fill" style="width: 25%"></div>
</div>
</div>
<!-- 第一步:搜索航班 -->
<div class="form-card active" id="step1">
<h2>✈️ 搜索航班</h2>
<div class="input-group">
<input type="text" required>
<label>出发城市</label>
</div>
<div class="input-group">
<input type="text" required>
<label>目的城市</label>
</div>
</div>
<!-- 第二步:选择日期 -->
<div class="form-card" id="step2">
<h2>📅 选择出行日期</h2>
<div class="input-group">
<input type="date" required>
</div>
</div>
<!-- 第三步:乘客信息 -->
<div class="form-card" id="step3">
<h2>👤 乘客信息</h2>
<div class="input-group">
<input type="text" required>
<label>乘客姓名</label>
</div>
</div>
<!-- 第四步:支付确认 -->
<div class="form-card" id="step4">
<div class="success-animation">
<div class="checkmark">✓</div>
<h2>支付成功!</h2>
<p>您的机票已确认,祝您旅途愉快!</p>
</div>
</div>
<!-- 导航按钮 -->
<div class="btn-group">
<button class="btn btn-secondary" onclick="previousStep()">上一步</button>
<button class="btn btn-primary" onclick="nextStep()">下一步</button>
</div>
</div>
<script>
// 步骤控制逻辑
let currentStep = 1;
const totalSteps = 4;
function updateProgress() {
// 更新步骤指示器
document.querySelectorAll('.step').forEach((step, index) => {
step.classList.toggle('active', index < currentStep);
});
// 更新进度条
const progress = (currentStep - 1) / (totalSteps - 1) * 100;
document.querySelector('.progress-fill').style.width = `${progress}%`;
}
function nextStep() {
if (currentStep < totalSteps) {
document.getElementById(`step${currentStep}`).classList.remove('active');
currentStep++;
document.getElementById(`step${currentStep}`).classList.add('active');
updateProgress();
}
}
function previousStep() {
if (currentStep > 1) {
document.getElementById(`step${currentStep}`).classList.remove('active');
currentStep--;
document.getElementById(`step${currentStep}`).classList.add('active');
updateProgress();
}
}
</script>
</body>
</html>