Flexbox container, online
Six activities your students do on their own devices. See who's finished, and their scores.
Flexbox container in one minute
What students need to know
display: flex on section makes it a flex container. flex-direction: column makes its children stack vertically. Without flex-wrap: wrap, items stay on one line and may overflow. wrap lets them break onto a new row or column.
display: flex is the correct value. 'flexbox' is not valid — the property value is simply 'flex'. justify-content controls alignment along the main axis. align-items controls alignment along the cross axis.
Mistakes students make
- CSS declarations require a colon. It should be display: flex; not display flex;.
- 'rows' is not a valid value. The correct value is flex-direction: row; (singular).
- CSS property names must be lowercase. 'Flex-wrap' should be written as 'flex-wrap'.
- 'centre' is not a valid value. CSS uses American English spelling: justify-content: center;.
What students will learn in this module
Every question in Module 53
Quick questions
- Which CSS declaration turns an element into a flex container?Adisplay: flexboxBdisplay: flex
- What does flex-direction: column do?ALays flex items out vertically (top to bottom)BLays flex items out horizontally (left to right)
- What does flex-wrap: wrap do?AAllows items to move onto new lines when they run out of spaceBPrevents items from ever wrapping
- Which property aligns flex items along the main axis?Aalign-itemsBjustify-content
- True or false: align-items: center centres items along the main axis.AFalseBTrue
Key terms
Students type the meaning of:
display: flex
Match the pairs
nav {
display: flex;
flex-direction: row;
gap: 16px;
}Match it to what it doesdiv {
display: flex;
justify-content: space-between;
align-items: center;
}Match it to what it doesdisplay: flex turns an element into a flex container — its direct children become flex itemsMatch it to what it doesflex-wrap: wrap allows flex items to flow onto new lines when space runs outMatch it to what it doesnav { display: flexbox; }Match it to what it doesdiv { justify-content: centre; }Match it to what it doesFill in the blanks
nav { display: ____; }Hint: Type the display value that turns an element into a flex container
div { ______________: row; }Hint: Type the flexbox property name that sets the main axis direction
div { flex-direction: ___; }Hint: Type the flex-direction value that lays items out horizontally left to right
nav { display: flex; _________: wrap; }Hint: Type the flexbox property name that controls whether items wrap onto multiple lines
nav { _______________: center; }Hint: Type the flexbox property name that aligns items along the main axis
Spot the error
Question 1
Anav { display flex; }Bdiv { flex-direction: row; }Cp { flex-wrap: wrap; }
Question 2
Anav { display: flex; }Bdiv { flex-direction: rows; }Csection { flex-wrap: wrap; }
Question 3
Anav { display: flex; }Bdiv { flex-direction: row; }Csection { Flex-wrap: wrap; }
Question 4
Anav { display: flex; }Bdiv { flex-direction: row; }Csection { flex-wrap: wrap; }Dp { justify-content: centre; }
Question 5
Anav { display: flex; }Bdiv { flex-direction: column; }Csection { flex-wrap: wrap; }Dheader { justify-content: center; }Efooter { align-items: streetch; }
