<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>嬅給你聽</title>
<style>
body {
font-family: 'Microsoft JhengHei', '微軟正黑體', sans-serif;
background-color: #f5f0ff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
padding: 20px;
text-align: center;
}
.container {
background-color: white;
border-radius: 15px;
box-shadow: 0 5px 15px rgba(66, 13, 98, 0.2);
padding: 30px;
max-width: 500px;
width: 100%;
border-top: 10px solid #420D62;
}
h1 {
color: #420D62;
margin-bottom: 30px;
font-weight: 700;
font-size: 2.2em;
}
.lyric-box {
min-height: 180px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 20px 0;
padding: 20px;
border-left: 5px solid #420D62;
background-color: #f9f5ff;
border-radius: 0 8px 8px 0;
}
.lyric {
font-size: 18px;
line-height: 1.8;
color: #420D62;
font-weight: 500;
margin-bottom: 10px;
}
.song-title {
font-size: 16px;
color: #7a5a96;
font-style: italic;
}
.btn {
background-color: #420D62;
color: white;
border: none;
padding: 12px 25px;
font-size: 16px;
border-radius: 30px;
cursor: pointer;
transition: all 0.3s;
margin-top: 20px;
font-family: 'Microsoft JhengHei', '微軟正黑體', sans-serif;
}
.btn:hover {
background-color: #30094a;
transform: translateY(-2px);
box-shadow: 0 5px 10px rgba(66, 13, 98, 0.3);
}
.date {
color: #7a5a96;
margin-bottom: 20px;
font-size: 14px;
}
.footer {
margin-top: 30px;
font-size: 12px;
color: #ba9bdf;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
animation: fadeIn 0.6s ease-out;
}
</style>
</head>
<body>
<div class="container">
<h1>嬅給你聽</h1>
<div class="date" id="current-date"></div>
<div class="lyric-box">
<p class="lyric" id="lyric-text">點擊下方按鈕獲取今日歌詞</p>
<p class="song-title" id="song-title"></p>
</div>
<button class="btn" onclick="generateLyric()">今日歌詞</button>
<div class="footer">
每日一首歌,溫暖你的心
</div>
</div>
<script>
// =============================================
// 在這裡手動編輯歌詞庫
// 格式: { text: "歌詞內容", title: "《歌名》" }
// =============================================
const lyrics = [
{ text: "當時不用說話 只懂得哭泣", title: "《穿越》" },
{ text: "我也不是大無畏,我也不是不怕死", title: "《烈女》" },
// 您可以繼續添加更多歌詞,格式如下:
// { text: "您喜歡的歌詞", title: "《歌曲名稱》" },
// { text: "另一段歌詞", title: "《另一首歌》" }
];
// =============================================
// 歌詞編輯結束
// =============================================
// 顯示當前日期
function updateDate() {
const now = new Date();
const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
document.getElementById('current-date').textContent = now.toLocaleDateString('zh-TW', options);
}
// 生成隨機歌詞
function generateLyric() {
if (lyrics.length === 0) {
document.getElementById('lyric-text').textContent = "請先添加歌詞";
document.getElementById('song-title').textContent = "";
return;
}
const randomIndex = Math.floor(Math.random() * lyrics.length);
const lyricElement = document.getElementById('lyric-text');
const titleElement = document.getElementById('song-title');
lyricElement.textContent = lyrics[randomIndex].text;
titleElement.textContent = lyrics[randomIndex].title;
// 添加動畫效果
lyricElement.classList.remove('fade-in');
titleElement.classList.remove('fade-in');
void lyricElement.offsetWidth; // 觸發重繪
void titleElement.offsetWidth;
lyricElement.classList.add('fade-in');
titleElement.classList.add('fade-in');
}
// 頁面加載時更新日期
window.onload = updateDate;
</script>
</body>
</html>
index.html
index.html