摘要
今天用 Flexbox 與 CSS Grid 重新整理頁面結構:工具列橫向排好、任務安排區塊與歷史頁更清晰,加入基本 RWD 與一致的按鈕/表單外觀,讓作品看起來更像產品而不是雛型。
<head>
引入 styles.css,全頁即套用一致外觀。假設已具備:
<head>
<!-- [Day26-NEW] 全站樣式 -->
<link rel="stylesheet" href="styles.css" />
把以下三個工具列 <div>
補上 class="toolbar"
語錄牆工具列(#quoteWallSection):
<!-- [Day26-CHANGED] 加上 .toolbar -->
<div class="toolbar" style="display:flex; gap:.5rem; align-items:center; flex-wrap:wrap;">
...
</div>
任務回顧工具列(歷史頁排序/篩選):
<!-- [Day26-CHANGED] 加上 .toolbar -->
<div class="toolbar">
<h3>任務回顧</h3>
<label for="sortSelect">排序:</label>
<select id="sortSelect">...</select>
<label for="filterSelect">篩選:</label>
<select id="filterSelect">...</select>
</div>
安排完成後的動作列(分享):
<!-- [Day26-CHANGED] 加上 .toolbar -->
<div id="postArrangeActions" class="toolbar" style="display:flex; gap:.5rem; margin-top:.5rem;">
<button id="btnShare" type="button">分享挑戰給好友</button>
</div>
註:style="..." 仍先保留以免破版,實際顯示會被 CSS 覆蓋;你也可以在確認無誤後移除 inline style。
/* ========== [Day26-NEW] 全站樣式:styles.css ========== */
/* CSS 變數(可於 Day 27 調色用) */
:root {
--bg: #fafafa;
--card: #ffffff;
--text: #222;
--muted: #677;
--border: #e6e6e6;
--primary: #3b82f6; /* 按鈕主色 */
--primary-600: #2563eb;
--focus: #94c0ff;
--radius: 12px;
--maxw: 1080px;
--space-1: .25rem;
--space-2: .5rem;
--space-3: .75rem;
--space-4: 1rem;
}
/* 任何 hidden 元素都強制不佔位(避免被後續 display 覆蓋) */
[hidden] { display: none !important; }
/* Reset(簡化版) */
* { box-sizing: border-box; }
html, body {
margin: 0;
padding: 0;
color: var(--text);
background: var(--bg);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
line-height: 1.5;
}
/* 主容器寬度 */
body > section,
#recordFormSection,
#historySection,
#taskScheduleSection,
#resonanceScreen {
max-width: var(--maxw);
margin: 0 auto;
padding: var(--space-4);
}
/* 卡片化區塊(常見 section) */
#recordFormSection,
#moodTestSection,
#moodDecisionSection,
#taskScheduleSection,
#historySection,
#resonanceScreen {
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
}
/* 標題層級 */
h1, h2, h3 {
margin: .2em 0 .6em;
}
.muted {
color: var(--muted);
}
/* 表單與按鈕的一致性 */
input[type="text"],
input[type="search"],
select,
button {
font: inherit;
}
input[type="text"],
input[type="search"],
select {
padding: .5rem .6rem;
border: 1px solid var(--border);
border-radius: 8px;
background: #fff;
min-height: 2.25rem;
}
input:focus,
select:focus,
button:focus {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
button {
padding: .5rem .8rem;
border: 1px solid var(--border);
border-radius: 10px;
background: #fff;
cursor: pointer;
}
button:hover { background: #f7f7f7; }
button:disabled { opacity: .6; cursor: not-allowed; }
#submitBtn,
#btnStartNow,
#btnShare,
#btnBackupNow,
#btnExportJSON,
#btnExportCSV,
#btnExportQuoteJSON {
background: var(--primary);
color: #fff;
border-color: transparent;
}
#submitBtn:hover,
#btnStartNow:hover,
#btnShare:hover,
#btnBackupNow:hover,
#btnExportJSON:hover,
#btnExportCSV:hover,
#btnExportQuoteJSON:hover {
background: var(--primary-600);
}
/* 工具列(水平置中 + 可換行) */
.toolbar {
display: flex;
gap: var(--space-2);
align-items: center;
flex-wrap: wrap;
}
/* 語錄清單與歷史清單的 list 間距 */
#quoteList,
#historyList,
#moodStatsList,
#moodTrendList {
padding-left: 1.25rem;
}
#quoteList li,
#historyList li {
margin: .4rem 0;
}
/* 任務安排:格線與拖曳高亮 */
.time-grid {
display: grid !important; /* 覆蓋內嵌 style */
grid-template-columns: repeat(3, 1fr);
gap: .75rem;
margin-top: .5rem;
}
.time-slot {
min-height: 56px;
border: 1px dashed var(--border);
border-radius: 10px;
background: #fff;
padding: .5rem;
}
.time-slot.dropping {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
/* 任務卡 */
#taskCard {
border: 1px solid var(--border) !important;
border-radius: 10px !important;
padding: .5rem !important;
background: #fff !important;
}
/* 歷史頁:使用 Grid 重排多區塊 */
#historySection { display: block; }
#quoteWallSection { margin-top: 1rem; }
/* 讓「任務回顧(排序/篩選+列表)與語錄牆」各自成塊 */
#quoteWallSection { order: 1; }
#historySection > .toolbar,
#historySection > ul,
#exportSection,
#cloudBackupSection {
order: 2;
}
/* Canvas 容器高度(保險) */
#moodChartWrap,
#moodTrendWrap,
#moodPieWrap {
position: relative;
}
#moodChartWrap { height: 260px !important; max-width: 680px; }
#moodTrendWrap { height: 260px !important; max-width: 680px; }
#moodPieWrap { height: 240px !important; max-width: 560px; }
/* 進場畫面與回訪卡片的間距微調 */
#revisitIntro > div { margin: .5rem 0; }
樣式沒生效
<head>
正確加入 <link rel="stylesheet" href="styles.css">
?工具列擠成一團
外層要有 .toolbar;避免內部再寫 display:block!important; 覆蓋。
Grid 三欄失效
.time-grid 需存在,且未被 inline style 覆蓋(已用 !important 覆蓋,可以在確認無誤後移除 inline style。)。
拖曳高亮沒效果
Chart 區高度怪異
#moodChartWrap / #moodTrendWrap / #moodPieWrap 的高度已在 CSS 固定;若你曾在 JS 動態改高,建議移除以避免衝突。
歷史區塊一開始就占位
確認 historySection 起始有 hidden,且 CSS 有 [hidden]{display:none!important;}。