本頁只練什麼
能用有限 spacing scale 管理 section 間距,讓相同層級只出現可預測的節奏值。
每個區塊各寫任意 margin 會逐頁漂移;token 化節奏能讓新增內容仍維持一致層級與密度。
要修改的檔案:files/starter/style.css
定位:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。|依 starter-2 定位,只修改「區塊間距節奏」的責任。
LESSON-08 · TOPIC 02
能用有限 spacing scale 管理 section 間距,讓相同層級只出現可預測的節奏值。
能用有限 spacing scale 管理 section 間距,讓相同層級只出現可預測的節奏值。
每個區塊各寫任意 margin 會逐頁漂移;token 化節奏能讓新增內容仍維持一致層級與密度。
要修改的檔案:files/starter/style.css
定位:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。|依 starter-2 定位,只修改「區塊間距節奏」的責任。
先結果,再原理;完成後要能說出自己看見的證據。
首頁四個 section 各自由不同人加入,垂直留白看似相近卻沒有一致規則。
起始狀態:第二個 section 使用任意 13px margin-block-start。
runtime 的 margin-block-start 由 13px 變 32px;其他相同層級 section 使用同一 token。
驗收證據:runtime before=13px、after=32px、property=margin-block-start
首頁 hero、服務、案例、CTA 等同層區塊需要一致分隔時。
常見混淆:spacing rhythm 不是所有距離都一樣;不同結構層級可使用不同 token,但每層用途要一致。
這段程式是理解起點,不是要你直接跳過 Starter。
間距像音樂拍子,選少量固定拍點反覆使用,比每次憑感覺留白更整齊。
正式說法:A spacing scale is a constrained set of design token values used according to structural relationships;margin-block expresses vertical rhythm in logical flow direction。
:root{--space-sm:.5rem;--space-md:1rem;--space-lg:2rem}.page-section+.page-section{margin-block-start:var(--space-lg)}每一步都留下可觀察結果;如果沒看到,先看「卡住先查」。
檔案:files/starter/style.css 定位:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。
要做:先重新載入 Starter,記錄目前畫面、DOM、Computed、Console 或文件內容。
預期:能指出「在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。」目前的缺口。
證據:保存 files/starter/style.css 的目前狀態,並指出下一步只會修改哪個檔案責任。
卡住先查:確認開啟的是 files/starter/style.css,且定位到 在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。。
檔案:files/starter/style.css 定位:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。
要做:執行實驗替第二個 section 切換 use-spacing-token class,讀取 computed margin-block-start。
預期:runtime 的 margin-block-start 由 13px 變 32px;其他相同層級 section 使用同一 token。
證據:runtime before=13px、after=32px、property=margin-block-start
卡住先查:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。
檔案:files/starter/style.css 定位:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。
要做:重新整理頁面,再逐項比對預期結果與 evidence。
預期:runtime 的 margin-block-start 由 13px 變 32px;其他相同層級 section 使用同一 token。
證據:runtime before=13px、after=32px、property=margin-block-start
卡住先查:在 Computed 讀第二個 section 的 margin-block-start,先記錄目前是否屬於 spacing scale。
這個示範只讓你看懂概念,不會替你修改 Starter,也不會自動宣告完成。
勾選只是學習紀錄;真正完成仍要回到 Starter 的實際結果。
先列出目前所有 section 間距,只留下有限尺度。
同層 section 統一使用 --space-lg:2rem。
完整解答與原因:將任意 13px 改為 var(--space-lg)=32px,讓同層新增區塊仍有可預測節奏。