Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!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;
- font-family: 'Microsoft YaHei', sans-serif;
- }
- body {
- background-color: #fff5f5;
- color: #333;
- line-height: 1.6;
- }
- .container {
- max-width: 1000px;
- margin: 0 auto;
- padding: 20px;
- }
- header {
- text-align: center;
- padding: 30px 0;
- background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
- color: white;
- border-radius: 10px;
- margin-bottom: 30px;
- box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
- }
- h1 {
- font-size: 2.5rem;
- margin-bottom: 10px;
- }
- .subtitle {
- font-size: 1.2rem;
- opacity: 0.9;
- }
- .section {
- background-color: white;
- border-radius: 10px;
- padding: 25px;
- margin-bottom: 30px;
- box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
- }
- h2 {
- color: #ff6b81;
- margin-bottom: 20px;
- padding-bottom: 10px;
- border-bottom: 2px solid #ffecef;
- }
- .timer {
- font-size: 1.8rem;
- text-align: center;
- margin: 20px 0;
- color: #ff6b81;
- font-weight: bold;
- }
- .timer span {
- display: inline-block;
- margin: 0 5px;
- padding: 5px 10px;
- background-color: #ffecef;
- border-radius: 5px;
- }
- .gallery {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
- gap: 15px;
- margin-top: 20px;
- }
- .photo {
- position: relative;
- overflow: hidden;
- border-radius: 8px;
- height: 200px;
- box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
- transition: transform 0.3s;
- }
- .photo:hover {
- transform: translateY(-5px);
- }
- .photo img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- transition: transform 0.5s;
- }
- .photo:hover img {
- transform: scale(1.05);
- }
- .photo .caption {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- background: rgba(0, 0, 0, 0.6);
- color: white;
- padding: 8px;
- font-size: 0.9rem;
- transform: translateY(100%);
- transition: transform 0.3s;
- }
- .photo:hover .caption {
- transform: translateY(0);
- }
- .upload-area {
- border: 2px dashed #ffb8c6;
- border-radius: 8px;
- padding: 20px;
- text-align: center;
- margin-top: 20px;
- cursor: pointer;
- transition: background 0.3s;
- }
- .upload-area:hover {
- background-color: #fff0f3;
- }
- .upload-area i {
- font-size: 2rem;
- color: #ff6b81;
- margin-bottom: 10px;
- display: block;
- }
- #file-input {
- display: none;
- }
- .story {
- margin-top: 20px;
- }
- .milestone {
- display: flex;
- margin-bottom: 30px;
- position: relative;
- padding-left: 30px;
- }
- .milestone:last-child {
- margin-bottom: 0;
- }
- .milestone::before {
- content: '';
- position: absolute;
- left: 0;
- top: 0;
- width: 15px;
- height: 15px;
- background-color: #ff6b81;
- border-radius: 50%;
- }
- .milestone::after {
- content: '';
- position: absolute;
- left: 7px;
- top: 15px;
- width: 1px;
- height: calc(100% + 30px);
- background-color: #ffb8c6;
- }
- .milestone:last-child::after {
- display: none;
- }
- .milestone-date {
- font-weight: bold;
- color: #ff6b81;
- margin-bottom: 5px;
- }
- .milestone-content {
- flex: 1;
- }
- .milestone-title {
- font-size: 1.2rem;
- margin-bottom: 10px;
- color: #333;
- }
- .milestone-description {
- color: #666;
- }
- .memory-box {
- background-color: #fff9fa;
- border-left: 4px solid #ff6b81;
- padding: 15px;
- margin: 20px 0;
- border-radius: 0 5px 5px 0;
- }
- .memory-title {
- font-weight: bold;
- margin-bottom: 10px;
- color: #ff6b81;
- }
- .btn {
- display: inline-block;
- background-color: #ff6b81;
- color: white;
- padding: 10px 20px;
- border-radius: 30px;
- text-decoration: none;
- margin-top: 10px;
- border: none;
- cursor: pointer;
- transition: background 0.3s, transform 0.2s;
- }
- .btn:hover {
- background-color: #ff4757;
- transform: translateY(-2px);
- }
- .btn-ghost {
- background-color: transparent;
- border: 1px solid #ff6b81;
- color: #ff6b81;
- }
- .btn-ghost:hover {
- background-color: #fff0f3;
- }
- footer {
- text-align: center;
- padding: 20px;
- color: #888;
- font-size: 0.9rem;
- }
- @media (max-width: 768px) {
- .gallery {
- grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
- }
- h1 {
- font-size: 2rem;
- }
- .timer {
- font-size: 1.4rem;
- }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <header>
- <h1>我们的恋爱记录</h1>
- <p class="subtitle">记录每一个甜蜜瞬间</p>
- </header>
- <section class="section" id="timer-section">
- <h2>在一起的时间</h2>
- <div class="timer" id="love-timer">
- <span id="years">0</span>年
- <span id="months">0</span>月
- <span id="days">0</span>天
- <span id="hours">0</span>小时
- <span id="minutes">0</span>分钟
- <span id="seconds">0</span>秒
- </div>
- <div class="memory-box">
- <div class="memory-title">纪念日</div>
- <p>我们的故事开始于 <strong id="start-date">2024-07-08</strong></p>
- <button class="btn btn-ghost" id="edit-date-btn">修改日期</button>
- <div id="date-edit-form" style="display: none; margin-top: 15px;">
- <input type="date" id="new-date-input" style="padding: 8px; border: 1px solid #ffb8c6; border-radius: 5px;">
- <button class="btn" id="save-date-btn" style="margin-left: 10px;">保存</button>
- </div>
- </div>
- </section>
- <section class="section" id="gallery-section">
- <h2>甜蜜相册</h2>
- <p>记录我们在一起的每一个美好瞬间</p>
- <div class="gallery" id="photo-gallery">
- <!-- 示例照片 -->
- <div class="photo">
- <img src="https://images.unsplash.com/photo-1518199266791-5375a83190b7?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80" alt="我们的照片">
- <div class="caption">第一次约会</div>
- </div>
- <div class="photo">
- <img src="https://images.unsplash.com/photo-1494774157365-9e04c6720e47?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80" alt="我们的照片">
- <div class="caption">海边旅行</div>
- </div>
- <div class="photo">
- <img src="https://images.unsplash.com/photo-1529333166437-7750a6dd5a70?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=80" alt="我们的照片">
- <div class="caption">生日惊喜</div>
- </div>
- </div>
- <div class="upload-area" id="upload-area">
- <i>📷</i>
- <p>点击或拖拽照片到这里上传</p>
- <input type="file" id="file-input" accept="image/*" multiple>
- </div>
- </section>
- <section class="section" id="story-section">
- <h2>我们的故事</h2>
- <p>记录我们爱情旅程中的每一个重要时刻</p>
- <div class="story">
- <div class="milestone">
- <div class="milestone-content">
- <div class="milestone-date">2024年6月23日</div>
- <h3 class="milestone-title">初次在TT相遇</h3>
- <p class="milestone-description">我们聊了很久,发现彼此有很多共同爱好。</p>
- </div>
- </div>
- <div class="milestone">
- <div class="milestone-content">
- <div class="milestone-date">2024年7月08日</div>
- <h3 class="milestone-title">第1次约会见面</h3>
- <p class="milestone-description">我去陵水找的你,我们去了那家小面馆,我和你吃着面聊着天,一起逛街 一起散步 买好多好吃的</p>
- </div>
- </div>
- <div class="milestone">
- <div class="milestone-content">
- <div class="milestone-date">2024年8月20日</div>
- <h3 class="milestone-title">正式在一起</h3>
- <p class="milestone-description">在海边的日落时分,你牵起我的手,问我愿不愿意做你的男/女朋友。那一刻,海浪声都掩盖不了我的心跳。</p>
- </div>
- </div>
- <div class="milestone">
- <div class="milestone-content">
- <div class="milestone-date">2024年12月24日</div>
- <h3 class="milestone-title">第一个圣诞节</h3>
- <p class="milestone-description">你送我的围巾我到现在还戴着,虽然织得有点歪歪扭扭,但那是你熬夜一周的成果,是我收到过最温暖的礼物。</p>
- </div>
- </div>
- </div>
- <div class="memory-box">
- <div class="memory-title">添加新故事</div>
- <form id="new-memory-form">
- <div style="margin-bottom: 10px;">
- <label for="memory-date" style="display: block; margin-bottom: 5px; color: #666;">日期</label>
- <input type="date" id="memory-date" style="padding: 8px; border: 1px solid #ffb8c6; border-radius: 5px; width: 100%;">
- </div>
- <div style="margin-bottom: 10px;">
- <label for="memory-title" style="display: block; margin-bottom: 5px; color: #666;">标题</label>
- <input type="text" id="memory-title" placeholder="例如:第一次旅行" style="padding: 8px; border: 1px solid #ffb8c6; border-radius: 5px; width: 100%;">
- </div>
- <div style="margin-bottom: 10px;">
- <label for="memory-description" style="display: block; margin-bottom: 5px; color: #666;">描述</label>
- <textarea id="memory-description" rows="4" placeholder="写下你们的甜蜜回忆..." style="padding: 8px; border: 1px solid #ffb8c6; border-radius: 5px; width: 100%; resize: vertical;"></textarea>
- </div>
- <button type="submit" class="btn">添加故事</button>
- </form>
- </div>
- </section>
- <section class="section" id="wishes-section">
- <h2>爱的留言</h2>
- <p>写下你想对TA说的话</p>
- <div class="memory-box">
- <textarea id="love-note" rows="4" placeholder="亲爱的,我想对你说..." style="padding: 10px; border: 1px solid #ffb8c6; border-radius: 5px; width: 100%; margin-bottom: 10px; resize: vertical;"></textarea>
- <button class="btn" id="save-note-btn">保存留言</button>
- </div>
- <div id="saved-notes">
- <!-- 留言将在这里显示 -->
- </div>
- </section>
- <footer>
- <p>❤️ 用心记录我们的爱情 ❤️</p>
- <p>最后更新: <span id="last-update"></span></p>
- </footer>
- </div>
- <script>
- // 计时器功能
- function updateTimer() {
- const startDateStr = localStorage.getItem('loveStartDate') || document.getElementById('start-date').textContent;
- const startDate = new Date(startDateStr);
- const now = new Date();
- let diff = now - startDate;
- const years = Math.floor(diff / (1000 * 60 * 60 * 24 * 365));
- diff -= years * (1000 * 60 * 60 * 24 * 365);
- const months = Math.floor(diff / (1000 * 60 * 60 * 24 * 30));
- diff -= months * (1000 * 60 * 60 * 24 * 30);
- const days = Math.floor(diff / (1000 * 60 * 60 * 24));
- diff -= days * (1000 * 60 * 60 * 24);
- const hours = Math.floor(diff / (1000 * 60 * 60));
- diff -= hours * (1000 * 60 * 60);
- const minutes = Math.floor(diff / (1000 * 60));
- diff -= minutes * (1000 * 60);
- const seconds = Math.floor(diff / 1000);
- document.getElementById('years').textContent = years;
- document.getElementById('months').textContent = months;
- document.getElementById('days').textContent = days;
- document.getElementById('hours').textContent = hours;
- document.getElementById('minutes').textContent = minutes;
- document.getElementById('seconds').textContent = seconds;
- document.getElementById('start-date').textContent = startDate.toISOString().split('T')[0];
- }
- // 修改日期功能
- document.getElementById('edit-date-btn').addEventListener('click', function() {
- const form = document.getElementById('date-edit-form');
- form.style.display = form.style.display === 'none' ? 'block' : 'none';
- });
- document.getElementById('save-date-btn').addEventListener('click', function() {
- const newDate = document.getElementById('new-date-input').value;
- if (newDate) {
- localStorage.setItem('loveStartDate', newDate);
- document.getElementById('date-edit-form').style.display = 'none';
- updateTimer();
- }
- });
- // 初始化日期输入框
- window.addEventListener('DOMContentLoaded', function() {
- const savedDate = localStorage.getItem('loveStartDate');
- if (savedDate) {
- document.getElementById('start-date').textContent = savedDate;
- document.getElementById('new-date-input').value = savedDate;
- } else {
- const today = new Date().toISOString().split('T')[0];
- document.getElementById('new-date-input').value = today;
- }
- // 更新最后修改时间
- const lastUpdate = new Date();
- document.getElementById('last-update').textContent = lastUpdate.toLocaleString();
- // 加载保存的照片
- loadSavedPhotos();
- // 加载保存的故事
- loadSavedMemories();
- // 加载保存的留言
- loadSavedNotes();
- });
- // 照片上传功能
- const uploadArea = document.getElementById('upload-area');
- const fileInput = document.getElementById('file-input');
- uploadArea.addEventListener('click', function() {
- fileInput.click();
- });
- uploadArea.addEventListener('dragover', function(e) {
- e.preventDefault();
- uploadArea.style.backgroundColor = '#fff0f3';
- });
- uploadArea.addEventListener('dragleave', function() {
- uploadArea.style.backgroundColor = '';
- });
- uploadArea.addEventListener('drop', function(e) {
- e.preventDefault();
- uploadArea.style.backgroundColor = '';
- if (e.dataTransfer.files.length > 0) {
- handleFiles(e.dataTransfer.files);
- }
- });
- fileInput.addEventListener('change', function() {
- if (fileInput.files.length > 0) {
- handleFiles(fileInput.files);
- }
- });
- function handleFiles(files) {
- const gallery = document.getElementById('photo-gallery');
- for (let i = 0; i < files.length; i++) {
- const file = files[i];
- if (file.type.startsWith('image/')) {
- const reader = new FileReader();
- reader.onload = function(e) {
- const photoDiv = document.createElement('div');
- photoDiv.className = 'photo';
- const img = document.createElement('img');
- img.src = e.target.result;
- img.alt = '我们的照片';
- const caption = document.createElement('div');
- caption.className = 'caption';
- caption.textContent = '新照片';
- photoDiv.appendChild(img);
- photoDiv.appendChild(caption);
- gallery.appendChild(photoDiv);
- // 保存到本地存储
- savePhotoToLocal(e.target.result, '新照片');
- };
- reader.readAsDataURL(file);
- }
- }
- }
- function savePhotoToLocal(imageData, caption) {
- let savedPhotos = JSON.parse(localStorage.getItem('lovePhotos')) || [];
- savedPhotos.push({ imageData, caption });
- localStorage.setItem('lovePhotos', JSON.stringify(savedPhotos));
- }
- function loadSavedPhotos() {
- const savedPhotos = JSON.parse(localStorage.getItem('lovePhotos')) || [];
- const gallery = document.getElementById('photo-gallery');
- // 保留示例照片
- if (savedPhotos.length === 0) return;
- // 清空示例照片
- gallery.innerHTML = '';
- savedPhotos.forEach(photo => {
- const photoDiv = document.createElement('div');
- photoDiv.className = 'photo';
- const img = document.createElement('img');
- img.src = photo.imageData;
- img.alt = '我们的照片';
- const caption = document.createElement('div');
- caption.className = 'caption';
- caption.textContent = photo.caption;
- photoDiv.appendChild(img);
- photoDiv.appendChild(caption);
- gallery.appendChild(photoDiv);
- });
- }
- // 故事功能
- document.getElementById('new-memory-form').addEventListener('submit', function(e) {
- e.preventDefault();
- const date = document.getElementById('memory-date').value;
- const title = document.getElementById('memory-title').value;
- const description = document.getElementById('memory-description').value;
- if (date && title && description) {
- addNewMemory(date, title, description);
- // 清空表单
- document.getElementById('memory-date').value = '';
- document.getElementById('memory-title').value = '';
- document.getElementById('memory-description').value = '';
- }
- });
- function addNewMemory(date, title, description) {
- const storyDiv = document.querySelector('.story');
- const milestone = document.createElement('div');
- milestone.className = 'milestone';
- const content = document.createElement('div');
- content.className = 'milestone-content';
- const dateElement = document.createElement('div');
- dateElement.className = 'milestone-date';
- dateElement.textContent = formatDate(date);
- const titleElement = document.createElement('h3');
- titleElement.className = 'milestone-title';
- titleElement.textContent = title;
- const descElement = document.createElement('p');
- descElement.className = 'milestone-description';
- descElement.textContent = description;
- content.appendChild(dateElement);
- content.appendChild(titleElement);
- content.appendChild(descElement);
- milestone.appendChild(content);
- // 插入到第一个位置
- storyDiv.insertBefore(milestone, storyDiv.firstChild);
- // 保存到本地存储
- saveMemoryToLocal(date, title, description);
- }
- function formatDate(dateStr) {
- const date = new Date(dateStr);
- return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
- }
- function saveMemoryToLocal(date, title, description) {
- let savedMemories = JSON.parse(localStorage.getItem('loveMemories')) || [];
- savedMemories.unshift({ date, title, description });
- localStorage.setItem('loveMemories', JSON.stringify(savedMemories));
- }
- function loadSavedMemories() {
- const savedMemories = JSON.parse(localStorage.getItem('loveMemories')) || [];
- const storyDiv = document.querySelector('.story');
- // 保留示例故事
- if (savedMemories.length === 0) return;
- // 清空示例故事
- storyDiv.innerHTML = '';
- savedMemories.forEach(memory => {
- const milestone = document.createElement('div');
- milestone.className = 'milestone';
- const content = document.createElement('div');
- content.className = 'milestone-content';
- const dateElement = document.createElement('div');
- dateElement.className = 'milestone-date';
- dateElement.textContent = formatDate(memory.date);
- const titleElement = document.createElement('h3');
- titleElement.className = 'milestone-title';
- titleElement.textContent = memory.title;
- const descElement = document.createElement('p');
- descElement.className = 'milestone-description';
- descElement.textContent = memory.description;
- content.appendChild(dateElement);
- content.appendChild(titleElement);
- content.appendChild(descElement);
- milestone.appendChild(content);
- storyDiv.appendChild(milestone);
- });
- }
- // 留言功能
- document.getElementById('save-note-btn').addEventListener('click', function() {
- const note = document.getElementById('love-note').value;
- if (note.trim()) {
- saveNote(note);
- document.getElementById('love-note').value = '';
- }
- });
- function saveNote(note) {
- let savedNotes = JSON.parse(localStorage.getItem('loveNotes')) || [];
- savedNotes.unshift({
- text: note,
- date: new Date().toLocaleString()
- });
- localStorage.setItem('loveNotes', JSON.stringify(savedNotes));
- displayNotes();
- }
- function displayNotes() {
- const savedNotes = JSON.parse(localStorage.getItem('loveNotes')) || [];
- const notesContainer = document.getElementById('saved-notes');
- notesContainer.innerHTML = '';
- savedNotes.forEach(note => {
- const noteDiv = document.createElement('div');
- noteDiv.className = 'memory-box';
- noteDiv.style.marginTop = '15px';
- const noteText = document.createElement('p');
- noteText.textContent = note.text;
- noteText.style.marginBottom = '5px';
- const noteDate = document.createElement('div');
- noteDate.textContent = note.date;
- noteDate.style.fontSize = '0.8rem';
- noteDate.style.color = '#888';
- noteDate.style.textAlign = 'right';
- noteDiv.appendChild(noteText);
- noteDiv.appendChild(noteDate);
- notesContainer.appendChild(noteDiv);
- });
- }
- function loadSavedNotes() {
- displayNotes();
- }
- // 启动计时器
- setInterval(updateTimer, 1000);
- updateTimer();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement