Advanced CSS layout specialist for building complex, responsive layouts using CSS Grid, Flexbox, and modern positioning techniques.
Expert skill for creating sophisticated, responsive CSS layouts using modern techniques. Master CSS Grid, Flexbox, container queries, and advanced positioning patterns.
This skill specializes in complex layout challenges:
Trigger this skill with queries like:
Step 1: Requirements Analysis
Step 2: Layout Strategy
Step 3: Implementation
Three-column layout with header and footer, where side columns have fixed width and center column is fluid.
.holy-grail {
display: grid;
grid-template-areas:
"header header header"
"left main right"
"footer footer footer";
grid-template-columns: 200px 1fr 200px;
grid-template-rows: auto 1fr auto;
min-height: 100vh;
}
.header { grid-area: header; }
.left { grid-area: left; }
.main { grid-area: main; }
.right { grid-area: right; }
.footer { grid-area: footer; }
/* Responsive */
@media (max-width: 768px) {
.holy-grail {
grid-template-areas:
"header"
"main"
"left"
"right"
"footer";
grid-template-columns: 1fr;
}
}
Content area with collapsible sidebar.
.layout-with-sidebar {
display: grid;
grid-template-columns: 250px 1fr;
gap: 2rem;
}
.sidebar {
position: sticky;
top: 2rem;
height: fit-content;
}
/* Collapsed sidebar */
.layout-with-sidebar[data-sidebar="collapsed"] {
grid-template-columns: 60px 1fr;
}
@media (max-width: 1024px) {
.layout-with-sidebar {
grid-template-columns: 1fr;
}
.sidebar {
position: fixed;
transform: translateX(-100%);
transition: transform 0.3s;
}
.sidebar[data-open="true"] {
transform: translateX(0);
}
}
Flexible dashboard with resizable panels.
.dashboard {
display: grid;
grid-template-columns: repeat(12, 1fr);
gap: 1.5rem;
padding: 1.5rem;
}
.panel-large {
grid-column: span 8;
}
.panel-medium {
grid-column: span 6;
}
.panel-small {
grid-column: span 4;
}
@media (max-width: 768px) {
.panel-large,
.panel-medium,
.panel-small {
grid-column: span 12;
}
}
Pinterest-style masonry layout.
.masonry {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
grid-auto-rows: 10px;
gap: 1rem;
}
.masonry-item {
/* Items span rows based on content height */
grid-row-end: span var(--row-span);
}
Responsive card grid with auto-fit.
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
/* With maximum columns */
.card-grid-limited {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
max-width: 1400px;
margin: 0 auto;
}
@supports (width: min(300px, 100%)) {
.card-grid {
grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}
}
Component-responsive design independent of viewport.
.card-container {
container-type: inline-size;
container-name: card;
}
.card {
display: block;
}
@container card (min-width: 400px) {
.card {
display: grid;
grid-template-columns: 200px 1fr;
}
}
@container card (min-width: 600px) {
.card {
grid-template-columns: 300px 1fr;
}
}
Align nested grid items with parent grid.
.main-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
}
.nested-grid {
display: grid;
grid-column: span 2;
grid-template-columns: subgrid;
gap: 1rem;
}
Fixed positioning within scroll containers.
.scroll-container {
display: flex;
flex-direction: column;
height: 100vh;
}
.sticky-header {
position: sticky;
top: 0;
z-index: 10;
background: white;
}
.scrollable-content {
flex: 1;
overflow-y: auto;
}
.sticky-footer {
position: sticky;
bottom: 0;
z-index: 10;
background: white;
}
Mobile-first navigation patterns.
/* Mobile: Hamburger menu */
.nav {
display: flex;
flex-direction: column;
position: fixed;
top: 0;
left: 0;
width: 250px;
height: 100vh;
transform: translateX(-100%);
transition: transform 0.3s;
}
.nav[data-open="true"] {
transform: translateX(0);
}
/* Tablet: Horizontal */
@media (min-width: 768px) {
.nav {
position: static;
flex-direction: row;
width: auto;
height: auto;
transform: none;
}
}
/* Desktop: Full width with dropdowns */
@media (min-width: 1024px) {
.nav {
justify-content: space-between;
}
.nav-dropdown {
position: absolute;
display: none;
}
.nav-item:hover .nav-dropdown {
display: block;
}
}
scripts/layout_analyzer.py - Analyzes CSS layout complexity and suggests optimizations
Usage:
python scripts/layout_analyzer.py styles.css
scripts/breakpoint_generator.py - Generates responsive breakpoint templates
Usage:
python scripts/breakpoint_generator.py --output breakpoints.css
references/grid_complete_guide.md - Comprehensive CSS Grid guide with all properties and patterns
references/flexbox_complete_guide.md - Complete Flexbox reference with alignment patterns and use cases
references/responsive_patterns.md - Collection of responsive design patterns and breakpoint strategies
references/container_queries_guide.md - Modern container queries guide for component-based responsive design
references/layout_debugging.md - Techniques for debugging layout issues and common pitfalls
/* Base styles for mobile */
.container {
display: block;
padding: 1rem;
}
/* Tablet and up */
@media (min-width: 768px) {
.container {
display: grid;
grid-template-columns: repeat(2, 1fr);
padding: 2rem;
}
}
/* Desktop and up */
@media (min-width: 1024px) {
.container {
grid-template-columns: repeat(3, 1fr);
max-width: 1200px;
margin: 0 auto;
}
}
h1 {
font-size: clamp(2rem, 5vw, 4rem);
}
.container {
width: clamp(300px, 90%, 1200px);
padding: clamp(1rem, 3vw, 3rem);
}
:root {
--spacing-xs: clamp(0.5rem, 1vw, 0.75rem);
--spacing-sm: clamp(0.75rem, 2vw, 1rem);
--spacing-md: clamp(1rem, 3vw, 1.5rem);
--spacing-lg: clamp(1.5rem, 4vw, 2rem);
--spacing-xl: clamp(2rem, 5vw, 3rem);
}
CSS Grid
Flexbox
General Layout
Performance
.container {
width: min(90%, 1200px);
margin-inline: auto;
padding-inline: 1rem;
}
.full-bleed {
width: 100vw;
margin-left: calc(50% - 50vw);
margin-right: calc(50% - 50vw);
}
.video-container {
aspect-ratio: 16 / 9;
width: 100%;
}
.square {
aspect-ratio: 1;
}
.equal-height-columns {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-auto-rows: 1fr;
}
Grid items not aligning
Flexbox items overflowing
Responsive layout breaking
Performance issues
Use css-layout-builder when:
Choose other skills for:
Modern features support:
Use feature queries for progressive enhancement:
@supports (container-type: inline-size) {
/* Container query styles */
}