白話字

<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>隨機字母顯示</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: "Noto Sans TC", Arial, sans-serif;
background: linear-gradient(180deg, #f5f9ff 0%, #eef4ff 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
color: #1f2a44;
}
.container {
width: min(900px, 92vw);
min-height: 80vh;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 32px 24px 40px;
}
.top-area {
display: flex;
justify-content: center;
align-items: flex-start;
padding-top: 10px;
}
.start-btn {
background: #1976d2;
color: white;
border: none;
border-radius: 14px;
padding: 16px 42px;
font-size: 24px;
font-weight: 700;
cursor: pointer;
box-shadow: 0 10px 24px rgba(25, 118, 210, 0.28);
transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.start-btn:hover {
background: #1565c0;
transform: translateY(-2px);
box-shadow: 0 14px 28px rgba(25, 118, 210, 0.32);
}
.start-btn:active {
transform: translateY(0);
}
.columns {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 24px;
align-items: stretch;
}
.panel {
background: rgba(255, 255, 255, 0.92);
border-radius: 24px;
padding: 28px;
min-height: 280px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-shadow: 0 12px 30px rgba(31, 42, 68, 0.08);
border: 1px solid rgba(25, 118, 210, 0.08);
}
.panel-title {
font-size: 22px;
font-weight: 700;
margin-bottom: 24px;
color: #244a86;
letter-spacing: 1px;
}
.letter {
font-size: clamp(84px, 12vw, 140px);
font-weight: 800;
color: #0d47a1;
line-height: 1;
user-select: none;
}
.hint {
margin-top: 18px;
font-size: 15px;
color: #657089;
}
@media (max-width: 640px) {
.container {
min-height: auto;
gap: 28px;
padding: 24px 16px 28px;
}
.columns {
grid-template-columns: 1fr;
}
.panel {
min-height: 220px;
}
.start-btn {
width: 100%;
max-width: 280px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="top-area">
<button class="start-btn" id="startBtn">開始</button>
</div>
<div class="columns">
<div class="panel">
<div class="panel-title">左側欄位・子音</div>
<div class="letter" id="consonant">-</div>
<div class="hint">隨機顯示英文子音字母</div>
</div>
<div class="panel">
<div class="panel-title">右側欄位・母音</div>
<div class="letter" id="vowel">-</div>
<div class="hint">隨機顯示英文母音字母</div>
</div>
</div>
</div>
<script>
const consonants = ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z'];
const vowels = ['A', 'E', 'I', 'O', 'U'];
const consonantEl = document.getElementById('consonant');
const vowelEl = document.getElementById('vowel');
const startBtn = document.getElementById('startBtn');
let timer = null;
function getRandomItem(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function updateLetters() {
consonantEl.textContent = getRandomItem(consonants);
vowelEl.textContent = getRandomItem(vowels);
}
startBtn.addEventListener('click', () => {
updateLetters();
if (timer) {
clearInterval(timer);
}
timer = setInterval(updateLetters, 1000);
});
</script>
</body>
</html>