Positioning, online
Six activities your students do on their own devices. See who's finished, and their scores.
Positioning in one minute
What students need to know
position: relative nudges the element using offset properties. The space the element occupied in normal flow is preserved. The header scrolls normally until its top edge hits 0 from the viewport top, then it sticks in place like a fixed element.
z-index sets the stacking order. Higher values appear in front. It only works on elements with a non-static position. 'stack-order' is not a valid CSS property. The colon is required between the property name and its value. 'position absolute' without a colon is invalid CSS.
Mistakes students make
- CSS declarations require a colon. It should be position: absolute; not position absolute;.
- 'absolut' is a typo. The correct value is position: absolute;.
- CSS property names must be lowercase. 'Position' should be written as 'position'.
- 'stiky' is a typo. The correct value is position: sticky;.
What students will learn in this module
Every question in Module 52
Quick questions
- Which position value keeps an element in normal flow but allows offset properties?AstaticBrelative
- What does position: absolute do to an element?ARemoves it from normal flow and positions it relative to its nearest positioned ancestorBFixes it relative to the viewport
- True or false: offset properties (top, left) work on position: static elements.AFalseBTrue
- Which position value keeps an element visible as the page scrolls?AfixedBabsolute
- True or false: position: sticky always behaves like position: fixed.ATrueBFalse
Key terms
Students type the meaning of:
position
Match the pairs
.child {
position: absolute;
top: 0;
right: 0;
}Match it to what it doesnav {
position: fixed;
top: 0;
width: 100%;
}Match it to what it doesposition: relative offsets an element without removing it from normal flowMatch it to what it doesposition: sticky behaves like relative until a scroll threshold is reached, then sticksMatch it to what it doesdiv { position absolute; }Match it to what it doesp { position: relative; top: 10 px; }Match it to what it doesFill in the blanks
div { position: ________; }Hint: Type the position value that offsets an element from its normal flow position without removing it
p { position: ________; }Hint: Type the position value that removes an element from normal flow and positions it relative to its nearest positioned ancestor
nav { position: _____; top: 0; }Hint: Type the position value that fixes an element relative to the viewport — it stays visible on scroll
header { position: ______; top: 0; }Hint: Type the position value that behaves like relative until the element scrolls to the threshold, then sticks
div { position: absolute; ___: 20px; }Hint: Type the CSS offset property name that sets the distance from the top edge of the positioned ancestor
Spot the error
Question 1
Adiv { position absolute; }Bp { top: 10px; }Cspan { left: 20px; }
Question 2
Adiv { position: relative; }Bp { position: absolut; }Cspan { top: 5px; }
Question 3
Adiv { position: relative; }Bnav { position: fixed; }Cp { Position: absolute; }
Question 4
Adiv { position: relative; }Bp { position: absolute; }Cspan { top: 10px; }Da { position: stiky; }
Question 5
Adiv { position: relative; }Bnav { position: fixed; }Cp { position: absolute; }Dspan { top: 0; }Ea { position: statik; }
