Communitygithub.com

版面配置

協助處理分組、對齊、閱讀順序、響應式結構以及翻譯文字的預留空間,讓版面在調整大小、翻譯或鏡像翻轉時依然穩固。

版面配置 是什麼?

本技能專注於確保使用者介面版面在調整大小、翻譯成其他語言或鏡像翻轉成從右至左(RTL)方向時,仍能保持結構完整且易於使用。它提供了一套系統性的方法來分組元素、對齊內容、管理間距,並建立能隨內容成長或縮放而彈性調整的響應式結構。此技能涵蓋多種平台,並提供具體的偵測模式與修復建議,可應用於常見的 CSS 陷阱,例如溢出容器、固定高度斷行以及缺少邏輯屬性。它也會根據嚴重性協助報告違規情況,優先處理會阻擋內容或操作的高嚴重性問題。透過遵循這些指引,開發者能創建出更穩固、更易於在地化且更具無障礙性的佈局,減少未來需要進行的重構工作。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/LIKELION-CAPSULE/Landing_Page/tree/HEAD/.agents/skills/better-layout

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

佈局

此技能設定分組、對齊、間距和響應式結構。然後透過調整大小、翻譯以及為 RTL(從右至左)進行鏡像翻轉,對該結構進行壓力測試。

所有修正請寫入專案的樣式系統中。以下數字僅適用於專案沒有間距尺度或密度系統的情況;否則請使用其設計記號(token)。發現問題必須提供可展示的失敗案例,例如裁剪、重疊、鏡像錯亂或群組誤讀。與這些起始值不同的數值本身並非問題。

點擊區域和焦點行為屬於 better-accessibility。圓角、陰影和動畫屬於 better-ui。行長、文字間距和截斷機制屬於 better-typography。文字內容本身屬於 better-writing。

用間距分組,而非線條

優先使用間距分組,其次是背景形狀,最後才是分隔線,並且只在間距本身無法承載結構時使用。組與組之間的間距至少是組內間距的 2 倍,因此如果組內間距為 8px,則組與組之間的間距應為 16px 或更多。範例請參閱 grouping-and-alignment.md。

保持控制項與內容區別分明

為每個互動元素提供背景形狀、邊框、底線或一致的放置區域(例如工具列)。一個樣式與旁邊靜態文字相同的控制項,無法被辨識為控制項。請參閱 grouping-and-alignment.md。

對齊到共享邊緣

選定一小組對齊邊緣,並將所有東西放置在這些邊緣上。每個巢狀層級使用一個專案的間距步進,其中 16px 是一個有用的預設值。請參閱 grouping-and-alignment.md。

任何會鏡像翻轉的內容使用邏輯屬性

將依賴方向的佈局寫為起始(leading)和結尾(trailing):margin-inline-start、padding-inline-end、inset-inline-start、text-align: start。保留物理性的左和右給物理幾何,例如安全區域(safe-area)內邊距。對應表和 RTL 漸進規則請參閱 grouping-and-alignment.md。

按重要性排序

最重要的內容靠近頂部和起始邊緣。在一個行內,識別性內容領先,中繼資料和操作跟隨其後。視覺順序需符合 DOM 順序,因此永遠不要使用 order、row-reverse 或網格放置來將內容移出原始順序。請參閱 grouping-and-alignment.md。

每個視圖一個主要操作

每個視圖提供一個主要操作。一旦次要操作超過 3 個,就將它們放在選單後面。偏好使用一個短視圖連結到更深層,而不是一個長視圖在頂層顯示所有內容。better-colors 負責如何用顏色標記主要操作。

提示隱藏的內容

每一片螢幕外或折疊的內容都需要一個可見的提示。使用專案既有的提示,讓下一個項目在滾動邊緣露出 16–32px,或顯示一個揭露控制項(disclosure control)。

使用者需要的被截斷的值,必須有獲取完整文字的方式:展開控制項、詳細視圖或也可透過鍵盤觸及的工具提示。截斷機制是 better-typography 的責任。範例請參閱 spacing-and-adaptivity.md。

無邊框控制項需要更多間距

在沒有既定密度系統的情況下,相鄰的邊框或填充控制項之間從 12px 開始。無邊框文字和圖示控制項的可見字形之間留 24px,並計入每個按鈕自身的內間距。緊湊佈局可以使用更少的間距,只要點擊區域永不重疊且控制項保持區別即可。請參閱 spacing-and-adaptivity.md。

按鈕從邊緣向內縮排

在內容佈局中,將全寬按鈕保持在佈局外邊距內,在行動裝置上從內聯方向的 16px 附近開始。當邊到邊的操作遵循既定的平台介面、考慮安全區域並保持與系統 UI 可區分時,它們是可行的。請參閱 spacing-and-adaptivity.md。

內容延伸,控制項浮動

背景和多媒體延伸到視口邊緣。控制項和文字保持在佈局外邊距和安全區域內。env(safe-area-inset-*) 只有在視口中繼標籤包含 viewport-fit=cover 時才為非零值。

內容在黏性(sticky)介面下方滾動。將 scroll-padding-block-start 設定為黏性標題的高度,這樣定位的錨點和聚焦的元素永遠不會落在其下方。請參閱 spacing-and-adaptivity.md。

保持結構直到它無法容納

斷點來自內容,而非裝置預設。保持展開的佈局直到它無法容納,然後折疊。對於元件層級的適應,優先使用容器查詢(container queries),並首先測試最小和最大支援尺寸。請參閱 spacing-and-adaptivity.md。

為文字增長和裁剪做準備

翻譯後的字串會增長,而短字串增長的比例更大,因此一個單詞的按鈕標籤是螢幕上風險最高的元素。使用 max-width 和 min-height 來調整文字容器尺寸,切勿使用固定寬度或高度,並讓行可以換行。使用偽在地化(pseudo-localization)和一個長字串語言環境(例如德文)進行測試。

永遠不要將關鍵操作放在會因調整大小、縮放或滾動而被裁剪的地方。將其保留在正常流程或穩定的介面中。請參閱 spacing-and-adaptivity.md。

完成之前

偵測模式修正
grid-template-columns: … 1fr 或一個容納長文字或寬表格的 flex 子項,溢出其軌道在軌道上使用 minmax(0, 1fr),在 flex 子項上使用 min-width: 0
width: 100vw使用 width: 100%;100vw 包含滾動條,在桌面上會水平滾動
height: 100vh 在一個全高移動端面板上使用 100dvh,這樣瀏覽器工具列和鍵盤就不會覆蓋底部
在容納文字的盒子上使用帶有固定長度的 height:使用 min-height,或使用帶有 overflow-y: auto 的 max-height
@media (max-width: …) 在一個可重複使用的元件內部在元件的父元素上使用 @container
container-type: inline-size 在一個沒有寬度的 flex 項目、inline-block 或絕對定位元素上給予它一個明確的寬度;尺寸包含(size containment)會將收縮貼合(shrink-to-fit)的盒子摺疊為零
env(safe-area-inset-*) 且視口中繼標籤中沒有 viewport-fit=cover加上它,否則內邊距將解析為 0
將 inset-inline-* 或 *-inline-* 與 safe-area-inset-left 或 -right 結合使用使用物理性的 left 或 right 搭配匹配的內邊距,再加上一個 [dir="rtl"] 覆寫
float: left 在鏡像的 UI 上使用 float: inline-start
translateX 或 background-position: left 在鏡像的 UI 上一個 [dir="rtl"] 覆寫;兩者都沒有邏輯形式
黏性標題沒有 scroll-padding-block-start設定為標題高度

報告

嚴重性。 HIGH 會阻止在支援的視口中顯示內容或執行操作。在 320px 寬度或 200% 縮放下出現裁剪或重疊總是 HIGH,截斷的內容且沒有完整數值的取得方式也是如此。超過滾動邊緣或隱藏在揭開機制後但沒有可見提示的內容也是 HIGH。MEDIUM 會損害階層結構、閱讀順序或適應性。LOW 是孤立的對齊或間距優化。

驗證。 沒有瀏覽器時,檢查邏輯屬性是否取代物理屬性、容器和媒體查詢是否符合支援的視口列表,以及 DOM 順序是否符合視覺順序。使用瀏覽器時,檢查每個支援的寬度、320px、200% 縮放以及 RTL 鏡像。報告每個無法執行的檢查為 Not verified。

格式。 將發現的問題分組到它們違反的原則下,按嚴重性排序,每個根本原因一行,列出它出現的每一個位置:

嚴重性位置修改前修改後原因

位置 為 path/to/file:line。原因 指出所違反的原則和對使用者的影響。

當還有任何 HIGH 存在時,以 Block 結尾,否則以 Approve 結尾,並將其餘問題保留在表格中作為待辦工作。切勿對你未檢查的涵蓋範圍給予 Approve。如果沒有要報告的內容,請陳述 "No actionable layout findings" 並報告驗證。

Individual skills in this repo

This repo contains 14 individual skills — each has its own dedicated page.

LIKELION-CAPSULE/Landing_Page

Reviews and fixes keyboard and focus behavior, ARIA, accessible names, forms, screen-reader announcements, motion and zoom in your project against WCAG 2.2.

LIKELION-CAPSULE/Landing_Page

Helps you build and check a color system for your project. It generates palettes, names semantic tokens, converts between formats and measures contrast.

LIKELION-CAPSULE/Landing_Page

Combines all of the `better-*` skills into a single review across accessibility, layout, writing, typography, color and UI polish.

LIKELION-CAPSULE/Landing_Page

Sets and reviews how text renders in your product, from the type scale and spacing to font features, wrapping, truncation and punctuation.

LIKELION-CAPSULE/Landing_Page

Polishes the surfaces, icons and motion in your project with exact values for border radius, optical alignment, shadows, icon states and animation.

LIKELION-CAPSULE/Landing_Page

Writes and reviews your interface copy, from labels and errors to empty states and confirmations, so it matches your product's voice and tells people what to do next.

LIKELION-CAPSULE/Landing_Page

Renders a component you choose under every scenario that can reach it on a temporary page and stress tests it.

LIKELION-CAPSULE/Landing_Page

Try to break a piece of UI by feeding it worst-case data — long names, unbreakable emails, one-letter names, missing fields, huge counts, zero items, long labels, non-Latin text, emoji, extreme numbers — then render it behind a "Demo data / Worst case" toggle and report everything that broke, with the fix for each. Use when the user asks to stress-test, break, or find edge cases in a component or screen, or to "try the worst case". For visual design critique use emil-design-eng; for motion use review-animations.

LIKELION-CAPSULE/Landing_Page

Builds UI from a Figma file or a design image so it matches the design, using your project's existing tokens and components.

LIKELION-CAPSULE/Landing_Page

Explains how a website, a visual effect or an animation was built, from a live URL or a screenshot.

LIKELION-CAPSULE/Landing_Page

Reviews a branch, pull request or uncommitted change for the interface problems it introduced or regressed, across accessibility, layout, writing, typography, color and UI.

LIKELION-CAPSULE/Landing_Page

Make a web app feel native on a phone — the small CSS and meta-tag fixes that separate "a website in a browser" from something that feels installed. Covers sticky hover states, tap highlight flashes, the 100vh bug, inputs that zoom the page, laggy taps, pull-to-refresh hijacking scroll, content under the notch, long-press selecting button text, carousels that scroll the wrong way, mismatched status bars, and the rule that you test on real hardware. Use when a web app is being built for or reviewed on mobile, when something "works in Chrome but feels wrong on my phone", when building a PWA, a bottom sheet, a carousel, a full-screen layout, or any touch interaction. For motion itself use animate; for React Native use animate-expo.

LIKELION-CAPSULE/Landing_Page

Renders every state of a component you choose on a throwaway page, with mock data and a switcher, so you can work on each state.

LIKELION-CAPSULE/Landing_Page

Builds multiple variants of a component you're working on and helps you iterate and pick one.

相關技能