Flex Container — exercises and bug fixes
10 hands-on exercises and 10 find-the-bug challenges for the Flex Container lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(10)
- 1
Space out a navbar
easy15 minMake .navbar a flex container with its items spread apart using justify-content: space-between.
- Set .navbar to display: flex.
- Set justify-content: space-between.
- 2
Center a hero message
easy15 minCenter .hero-content both horizontally and vertically inside .hero using flexbox.
- Set .hero to display: flex.
- Set justify-content: center.
- Set align-items: center.
- 3
Wrap a row of cards
easy15 minMake .cards a flex container that wraps onto new lines when the cards don't fit, using flex-wrap: wrap.
- Set .cards to display: flex.
- Set flex-wrap: wrap.
- 4
Stack items in a flex column
easy15 minMake .stack a flex container laid out as a column (flex-direction: column) with its items centered horizontally.
- Set .stack to display: flex.
- Set flex-direction: column.
- Set align-items: center.
- 5
Build equal-width columns
easy15 minMake .columns a flex row where every .column grows to share the space equally, using flex: 1 on each column.
- 6
Create a flex container
easy10 minMake #row a flex container.
- 7
Use inline-flex
easy10 minMake #row an inline flex container.
- 8
Add a gap
easy10 minGive the flex container a 16px gap.
- 9
Separate row and column gaps
easy10 minSet a 10px row gap and a 30px column gap.
- 10
Build a padded flex bar
medium10 minFlex container with 20px padding and a 12px gap.
Find the bug(10)
- 1
Fix the toolbar that won't line up
easy15 min.toolbar was meant to lay its buttons out in a flex row, but display is set to block, so they stack. Fix the display value.
- 2
Fix the misspelled justify-content
easy15 minThe header's items should be spread apart with space-between, but a typo in the property value means it has no effect. Fix the value.
- 3
Fix the sidebar's wrong direction
easy15 min.sidebar's links should stack vertically as a column, but flex-direction is set to row, so they sit side by side. Fix the direction.
- 4
Fix the uncentered avatar row
easy15 min.avatar-row should vertically center its avatar and name, but align-items is set to flex-start, leaving the shorter item glued to the top. Fix it to center.
- 5
Fix the tag list that won't wrap
easy15 min.tag-list has many tags that overflow its box because flex-wrap is set to nowrap. Fix it so extra tags wrap onto new lines.
- 6
Fix the missing display
easy8 minFlex properties do nothing without display: flex.
- 7
Fix the misspelled value
easy8 minThe value is flex, not flexbox.
- 8
Fix the flex set on the items
easy8 minThe container needs display: flex, not the items.
- 9
Fix margin used instead of gap
easy8 minModern flex layouts space children with gap.
- 10
Fix the wrong gap property
easy8 minThe property is column-gap, not gap-x.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace