Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.54 KB

README.md

File metadata and controls

54 lines (36 loc) · 1.54 KB

26. Flexbox

Lay out one-dimensional groups.

Learn

  • main and cross axes
  • gap
  • justify-content
  • align-items
  • flex-grow
  • flex-basis
  • wrapping

Build

Build responsive navigation and a row of equal-height cards.

Check your work

  • Open the result in a browser and inspect the HTML and computed CSS.
  • Test at narrow and wide widths and use the keyboard for interactive elements.
  • Write down one thing you changed after testing.

Deep lesson

How it works

Flexbox arranges children along one main axis. justify-content distributes space on that axis; align-items works across it. flex-basis supplies a starting size, grow shares positive space, shrink handles shortage, and flex-wrap permits new lines. Gap creates consistent space between items. Use Flexbox for rows or columns whose contents determine their dimensions.

Common mistake

Using margin on every child can make edge spacing inconsistent. Remember that changing flex-direction also changes which axis is main.

Guided challenge

Make a navigation row that wraps and cards that become one column on small screens. Inspect flex-basis and grow in developer tools.

Completion check

  • Rebuild the core idea without copying the example line by line.
  • Explain the key HTML or CSS choice in your own words.
  • Test the result at a narrow width and with keyboard navigation where relevant.

Run the example

Open example.html in a browser. Edit style.css, save, and refresh.

Try: Change flex-basis from 12rem to 18rem and resize the browser.