Step 1 of 10
Start here: why won't these boxes line up?
These CSS flexbox exercises start with a problem everyone who builds pages meets: you put a logo, three links and a button in a nav bar, and they stack one under another instead of sitting in a row. Flexbox is the part of CSS that lines boxes up, shares out the space between them and lets them wrap, and you'll practise it here on real page parts.
You just watched five parts of a nav bar flow onto one line, cards grow to share a row and a button get pushed to the far end. Each of those moves is one or two lines of CSS, and by the end you'll write all of them yourself.
What you'll do
- Switch on flexbox and see what changes for the container and for its items.
- Place items along the main axis and across it, on a nav bar, a dashboard header and a chat.
- Size items with
flex-grow,flex-shrinkandflex-basis, and work out the widths by hand. - Build a whole page: a nav bar, a grid of cards and a footer.
By the end you can
- Read a flexbox layout and say which property puts each box where it is.
- Lay out nav bars, card rows and headers without floats, tables or fixed positions.
- Fix a layout that squeezes, overflows or sits in the wrong place.
You need a browser and a little CSS: a selector, a property and a value.