local-link/skills/css-dev-skills/skills/css-layout/SKILL.md
Create or fix layouts using modern CSS Grid, Flexbox, container queries, and logical properties. Includes a Grid vs Flexbox decision tree and patterns for common layouts. Use when the user asks for a CSS layout, grid layout, flexbox layout, sidebar layout, holy grail, card grid, centering, or layout fix.
npx skillsauth add lionad-morotar/local-tools css-layoutInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a senior CSS layout engineer. Build or fix layouts using modern CSS. Always generate code. For the full pattern catalog, see modern-patterns.md. For layout anti-patterns to avoid, see anti-patterns.md.
What are you laying out?
│
├─ 2D layout (rows AND columns)?
│ └─ CSS Grid
│ ├─ Known, named regions → grid-template-areas
│ ├─ Repeating uniform items → repeat(auto-fill, minmax())
│ ├─ Children need parent's tracks → subgrid
│ └─ Component-responsive → container queries + grid
│
├─ 1D layout (single row OR column)?
│ └─ Flexbox
│ ├─ Items should wrap → flex-wrap: wrap + gap
│ ├─ Items should stay in line → flex-shrink / overflow
│ └─ Even distribution → flex: 1 or justify-content: space-between
│
├─ Centering something?
│ ├─ Single element → place-items: center (grid) or margin: auto
│ ├─ Text → text-align: center + align vertical with flexbox
│ └─ Absolute overlay → position: absolute + inset: 0 + grid place-items
│
├─ Overlapping / stacking?
│ ├─ Controlled overlap → grid with shared grid-area
│ └─ Arbitrary positioning → position: absolute (only valid use)
│
└─ Need component-level responsiveness?
└─ container-type: inline-size + @container queries
Use when you have a semantic, named layout with distinct regions.
.page {
display: grid;
grid-template:
"header header" auto
"sidebar main" 1fr
"footer footer" auto
/ minmax(200px, 300px) 1fr;
min-height: 100dvh;
}
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }
@media (max-width: 48em) {
.page {
grid-template:
"header" auto
"main" 1fr
"sidebar" auto
"footer" auto
/ 1fr;
}
}
Use for repeating items that should fill available space.
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
gap: var(--space-m);
}
auto-fill creates empty tracks if space remains — use when you want consistent column widths.auto-fit collapses empty tracks — use when you want items to stretch to fill the row.min(280px, 100%) prevents overflow on small containers.Use when children need to align to the parent grid's tracks. Common for cards with aligned headers, bodies, and footers.
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: var(--space-m);
}
.card {
display: grid;
grid-template-rows: subgrid;
grid-row: span 3;
gap: var(--space-s);
}
Use for masonry-like packing when items have varying sizes.
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
grid-auto-flow: dense;
gap: var(--space-xs);
}
.gallery-item--wide { grid-column: span 2; }
.gallery-item--tall { grid-row: span 2; }
.nav {
display: flex;
align-items: center;
gap: var(--space-s);
flex-wrap: wrap;
}
.nav-spacer { margin-inline-start: auto; }
.tags {
display: flex;
flex-wrap: wrap;
gap: var(--space-2xs);
}
.equal-row {
display: flex;
gap: var(--space-m);
> * { flex: 1; }
}
body {
display: flex;
flex-direction: column;
min-height: 100dvh;
}
main { flex: 1; }
.center {
display: grid;
place-items: center;
}
.center {
display: flex;
justify-content: center;
align-items: center;
}
.center-block {
max-width: 60rem;
margin-inline: auto;
}
.overlay {
position: fixed;
inset: 0;
display: grid;
place-items: center;
}
Header, footer, sidebar, and main content with the content area taking remaining space.
body {
display: grid;
grid-template:
"header header" auto
"nav main" 1fr
"footer footer" auto
/ minmax(200px, 20%) 1fr;
min-height: 100dvh;
}
.layout {
display: grid;
grid-template-columns: fit-content(300px) 1fr;
gap: var(--space-l);
}
@media (max-width: 48em) {
.layout { grid-template-columns: 1fr; }
}
The sidebar takes its natural width, main content gets the rest.
.with-sidebar {
display: flex;
flex-wrap: wrap;
gap: var(--space-l);
}
.with-sidebar > :first-child { flex-basis: 250px; flex-grow: 1; }
.with-sidebar > :last-child { flex-basis: 0; flex-grow: 999; min-inline-size: 60%; }
body {
display: grid;
grid-template-rows: auto 1fr auto;
min-height: 100dvh;
}
Use container queries for component-level responsiveness. Media queries are for page-level layout shifts only.
.component-wrapper {
container-type: inline-size;
container-name: card;
}
.card-wrapper {
container-type: inline-size;
}
.card {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-s);
@container (inline-size >= 500px) {
grid-template-columns: 200px 1fr;
}
@container (inline-size >= 800px) {
grid-template-columns: 300px 1fr auto;
}
}
.card-title {
font-size: clamp(1rem, 3cqi, 1.5rem);
}
cqi = 1% of the container's inline size.
Always use logical properties instead of physical ones.
| Physical | Logical |
|----------|---------|
| width | inline-size |
| height | block-size |
| margin-left | margin-inline-start |
| margin-right | margin-inline-end |
| margin-top | margin-block-start |
| padding-left | padding-inline-start |
| top | inset-block-start |
| left | inset-inline-start |
| text-align: left | text-align: start |
| border-left | border-inline-start |
.element {
margin-block: var(--space-m);
padding-inline: var(--space-l);
border-inline-start: 3px solid var(--color-primary);
max-inline-size: 65ch;
}
gap for space between grid/flex children — never margin hacks.var(--space-s), var(--space-m), etc.clamp() for fluid spacing that adapts without breakpoints.float used for layoutgap)overflow-wrap: break-word)min() used in minmax() to prevent overflow: minmax(min(280px, 100%), 1fr)100dvh used instead of 100vh for full-height layoutstools
分批提交 Git 变更的完整工作流。当用户说"提交这个文件"、"帮我 commit"、"分批提交"、"整理提交计划"、"staged 的文件"、"git 提交"时触发
tools
从用户给出的文档片段中,提取"进阶必知"的深层知识,当用户提到"太简单了,给我几条秘密","面试必备的那种","八股文进阶"时触发
data-ai
批量给技能目录添加 disable-model-invocation,节省 token 开销。只保留需要 LLM 生成/分析/决策的技能有模型调用能力。
tools
open understand dashboard for user