014
LVL 01 — WAVE DEFENDER SESSION 014 DAY 14

FIX THE LAYOUT

🎫 PIXELCRAFT-004
🎨 Design | 🟢 Beginner | Priority: 🟠 High

Buttons in the toolbar stack vertically instead of horizontally. The main layout should be three panels: toolbar on the left, canvas in the center, settings on the right. Currently everything is stacked top to bottom.
CONCEPTS.UNLOCKED
📐
CSS Display Property
block (full-width stack), inline (flow in text), inline-block (flow + dimensions), none (hidden), flex (modern layout). Display controls the fundamental behavior.
Flexbox Container
display: flex on a container. Children become flex items. flex-direction: row (horizontal — default) or column (vertical). This determines the main axis.
⇔⇕
Alignment
justify-content (main axis): flex-start, center, space-between, space-around, space-evenly. align-items (cross axis): stretch, center, flex-start, flex-end.
Spacing & Wrapping
gap: space between flex items (no more margin hacks). flex-wrap: wrap items to the next line when they overflow instead of shrinking.
Flex Sizing
flex-grow (how much extra space to take), flex-shrink (how much to shrink), flex-basis (starting size). Shorthand: flex: 1 = "fill remaining space."
🏗
Building the App Layout
App shell: display: flex (toolbar | canvas | settings). Toolbar: flex-direction: column. Canvas: flex: 1 (takes remaining space). Settings: fixed width.
HANDS-ON.TASKS
01
Style the Toolbar as a Column

Make toolbar buttons stack vertically within the sidebar:

.toolbar { display: flex; flex-direction: column; width: 60px; align-items: center; gap: 4px; padding: 8px 4px; }
02
Build the Three-Panel App Layout
.app-container { display: flex; height: 100vh; } .toolbar { width: 60px; flex-shrink: 0; /* Never shrink below 60px */ } .canvas-area { flex: 1; /* Take ALL remaining space */ } .settings-panel { width: 280px; flex-shrink: 0; /* Never shrink below 280px */ }
flex: 1 is the magic. It tells the canvas to fill whatever space is left after the fixed-width panels. Resize the browser — the canvas adjusts, the sidebars stay fixed.
03
Align Items & Center the Canvas

Center the canvas element within its container and space out settings controls:

.canvas-area { flex: 1; display: flex; /* Nested flex! */ justify-content: center; /* Horizontal center */ align-items: center; /* Vertical center */ background-color: #0a0a1a; overflow: hidden; }
Centering used to be notoriously difficult in CSS. With Flexbox, it's two lines: justify-content: center + align-items: center. That's it.
04
DevTools Flexbox Overlay

Open DevTools → Elements → click the flex badge next to any flex container. This activates the Flexbox overlay — colored lines showing direction, gaps, and item sizes.

05
Flexbox Playground

Experiment with every justify-content value and see what they do:

ValueBehavior
flex-startPack items at the start
flex-endPack items at the end
centerPack items in the center
space-betweenEqual space between items, none at edges
space-aroundEqual space around each item
space-evenlyEqual space everywhere

Change values in DevTools and watch the layout shift in real time.

06
CSS Grid for Settings Panel

Introduce CSS Grid briefly for the settings panel layout — each filter control needs three columns:

.filter-group { display: grid; grid-template-columns: 80px 1fr 40px; align-items: center; gap: 8px; }
ColumnSizeContent
180px (fixed)Label text
21fr (fill remaining)Range slider
340px (fixed)Current value
07
Close the Ticket
git switch -c design/PIXELCRAFT-004-fix-layout git add src/styles/main.css src/index.html git commit -m "Implement three-panel Flexbox layout (PIXELCRAFT-004)" git push origin design/PIXELCRAFT-004-fix-layout # PR → Review → Merge → Close ticket ✅
CS.DEEP-DIVE

Layout is constraint satisfaction.

"This must be 60px wide. That must fill remaining space. These must be vertically centered." The browser's layout engine solves a system of constraints every time it renders a frame.

// This same class of problem appears in:

Spreadsheets    → resolving formulas with
                  circular references
Physics sims    → forces must balance
Scheduling      → jobs must fit in time slots
AI constraint   → Sudoku-solving by
  programming     eliminating impossible states

// The browser solves hundreds of layout
// constraints every single frame (60x/sec).
// Layout is computation.
"Flexbox Mastery"
[A] Complete Flexbox Froggy (flexboxfroggy.com) — all 24 levels. Screenshot your completion screen.
[B] Recreate the layout of a real app (Spotify, Slack, or VS Code) using only Flexbox. Focus on the top-level panel arrangement.
[C] Add a collapsible settings panel: when collapsed, the canvas expands to fill the space. (Hint: toggle a class that sets width: 0 + overflow: hidden.)
REF.MATERIAL
ARTICLE
CSS-Tricks
The most referenced Flexbox resource on the internet. Visual diagrams for every property. Bookmark this — you'll revisit it hundreds of times.
FLEXBOXREFERENCEESSENTIAL
TOOL
Codepip
Interactive game that teaches Flexbox by moving frogs to lily pads. 24 levels from basic to advanced. Essential practice.
INTERACTIVEGAMEESSENTIAL
VIDEO
Fireship
The fastest possible Flexbox overview. Watch for a quick mental model, then use the CSS-Tricks guide as your reference.
FLEXBOXQUICK
VIDEO
Web Dev Simplified
Practical walkthrough: container properties, item properties, real-world layout patterns. Covers everything from this session.
FLEXBOXPRACTICAL
TOOL
Codepip
Interactive game for CSS Grid — the complement to Flexbox Froggy. Play after this session to reinforce the Grid preview.
GRIDINTERACTIVEGAME
// LEAVE EXCITED BECAUSE
PixelCraft now looks like Photoshop or Figma — sidebar toolbar, center canvas, right settings panel. It looks like a REAL application. And it was just CSS Flexbox.