引言
在数字化时代,我们用代码记录情感。本文将展示如何通过HTML+CSS打造一个充满诗意的玫瑰告别纪念页,结合渐变色、动态交互和响应式设计等技术要点。
一、核心功能亮点
-
情感化配色方案
background: linear-gradient(135deg, #6a0f49, #2c0b1e);
使用葡萄酒红到深紫的渐变背景,营造庄重而浪漫的氛围。
-
动态时间轴设计
通过CSS transform实现悬停效果:.timeline-item { transition: transform 0.3s ease; } .timeline-item:hover { transform: translateX(10px); }
-
诗意排版美学
- 文字阴影增强层次
- 伪竖线分隔内容区域
- 图标字体精确布局
二、关键技术解析
-
响应式布局方案
@media (max-width: 768px) { .container { padding: 1rem; } h1 { font-size: 2rem; } }
确保移动端友好显示
-
玻璃拟态效果
background: rgba(0, 0, 0, 0.5); box-shadow: 0 0 20px rgba(255, 100, 150, 0.3);
通过透明度与阴影创造质感
-
元素定位技巧
.rose-icon { position: absolute; transform: translate(-50%, -50%); }
精确控制装饰图标位置
程序代码
<!DOCTYPE html>
<html lang="zh-CN">
<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;
}
body {
background: linear-gradient(135deg, #6a0f49, #2c0b1e);
color: #ffe6f2;
font-family: 'Microsoft YaHei', sans-serif;
line-height: 1.6;
min-height: 100vh;
padding: 2rem;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 2rem;
background: rgba(0, 0, 0, 0.5);
border-radius: 15px;
box-shadow: 0 0 20px rgba(255, 100, 150, 0.3);
}
h1 {
text-align: center;
font-size: 2.5rem;
margin-bottom: 2rem;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
position: relative;
}
.rose-icon {
width: 60px;
opacity: 0.8;
position: absolute;
transform: translate(-50%, -50%);
}
.content {
padding: 2rem;
border-left: 3px solid #ff6699;
margin: 2rem 0;
}
.poem {
font-style: italic;
text-align: center;
padding: 1.5rem;
background: rgba(255, 102, 153, 0.1);
border-radius: 10px;
margin: 2rem 0;
}
.timeline {
display: grid;
gap: 1.5rem;
margin-top: 2rem;
}
.timeline-item {
padding: 1rem;
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
transition: transform 0.3s ease;
}
.timeline-item:hover {
transform: translateX(10px);
}
@media (max-width: 768px) {
body {
padding: 1rem;
}
.container {
padding: 1rem;
}
h1 {
font-size: 2rem;
}
}
</style>
</head>
<body>
<div class="container">
<h1>
<img src="https://img.icons8.com/fluency/48/rose.png" alt="玫瑰" class="rose-icon">
告别玫瑰
<img src="https://img.icons8.com/fluency/48/rose.png" alt="玫瑰" class="rose-icon">
</h1>
<div class="content">
<p>在时光的长廊里,每一朵玫瑰都诉说着独特的故事。当花瓣最后一次轻触大地,不是终结,而是永恒的开始。</p>
<div class="poem">
<p>"刺的锋芒曾守护美的绽放</p>
<p>褪色的红是时光的勋章</p>
<p>零落成尘的刹那</p>
<p>芬芳已镌刻成永恒"</p>
</div>
<div class="timeline">
<div class="timeline-item">
<h3>萌芽之初</h3>
<p>2020.03.12 - 初次相遇在春雨绵绵的午后</p>
</div>
<div class="timeline-item">
<h3>盛放时刻</h3>
<p>2022.06.18 - 见证最灿烂的108朵同时绽放</p>
</div>
<div class="timeline-item">
<h3>永恒记忆</h3>
<p>2023.09.01 - 最后一片花瓣的谢幕演出</p>
</div>
</div>
</div>
</div>
</body>
</html>