Flexbox alignment, online
Six activities your students do on their own devices. See who's finished, and their scores.
Flexbox alignment in one minute
What students need to know
justify-content: center pushes all flex items to the centre of the main axis (horizontally for flex-direction: row). space-between places equal gaps between items only. space-around adds equal gaps on each side of every item, including at the edges.
CSS uses American English. The correct value is 'center', not 'centre'. Using 'centre' will be silently ignored.
Mistakes students make
- CSS declarations require a colon. It should be justify-content: center; not justify-content centre;.
- 'middle' is not a valid align-items value. Use align-items: center; to centre items on the cross axis.
- CSS property names must be lowercase. 'Align-items' should be written as 'align-items'.
- 'stretchy' is not a valid value. The correct value is align-content: stretch;.
What students will learn in this module
Every question in Module 54
Quick questions
- Which property aligns flex items along the main axis?Aalign-itemsBjustify-content
- What does align-items: center do?ACentres items along the cross axisBCentres items along the main axis
- Which justify-content value puts equal gaps between items with no space at the outer edges?Aspace-betweenBspace-around
- True or false: align-self overrides align-items for a single flex item.ATrueBFalse
- True or false: align-items: stretch is the default value.AFalseBTrue
Key terms
Students type the meaning of:
align-items
Match the pairs
nav {
display: flex;
justify-content: space-between;
align-items: center;
}Match it to what it does.card { align-self: flex-end; }Match it to what it doesjustify-content controls spacing and alignment along the main axisMatch it to what it doesalign-items aligns all flex items on the cross axis — overridden per item by align-selfMatch it to what it doesdiv { align-items: middle; }Match it to what it doesdiv { justify-content: centre; }Match it to what it doesFill in the blanks
nav { display: flex; ___________: center; }Hint: Type the flexbox property name that aligns items along the cross axis
div { display: flex; align-items: ______; }Hint: Type the alignment value that centres flex items on the cross axis
nav { _______________: space-between; }Hint: Type the flexbox property name that aligns items along the main axis
div { __________: flex-end; }Hint: Type the flexbox property name that overrides align-items for a single flex item
nav { justify-content: _____________; }Hint: Type the justify-content value that puts equal space between items with none at the edges
Spot the error
Question 1
Anav { justify-content centre; }Bdiv { align-items: center; }Csection { display: flex; }
Question 2
Anav { display: flex; }Bdiv { align-items: middle; }Csection { justify-content: center; }
Question 3
Anav { display: flex; }Bdiv { justify-content: space-between; }Csection { Align-items: center; }
Question 4
Anav { display: flex; }Bdiv { align-items: flex-start; }Csection { justify-content: center; }Dheader { align-content: stretchy; }
Question 5
Anav { display: flex; }Bdiv { align-items: center; }Csection { justify-content: flex-start; }Dheader { align-content: space-between; }Efooter { align-self: centre; }
