Positioning — relative, absolute, fixed and sticky — Concept Check
Questions on Positioning — relative, absolute, fixed and sticky. Positioning takes an element out of the normal flow, or anchors it while scrolling. The recurring question is always the same: positioned relative to what?
Questions in this quiz
8 questions on Positioning — relative, absolute, fixed and sticky — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer notices that a dropdown menu is not positioned correctly below its button. The button's parent has no specific positioning. What could be the issue?
- AThe dropdown is positioned relative to the page instead of the button.
- BThe dropdown is positioned relative to the viewport.
- CThe dropdown is positioned relative to the nearest sticky ancestor.
- DThe dropdown is positioned relative to the nearest static ancestor.
2.A sticky header is not sticking at the top of the page as expected. What could be the reason?
- AThe header is inside a fixed container.
- BThe header's parent has overflow: hidden.
- CThe header lacks a z-index value.
- DThe header is not absolutely positioned.
3.Which positioning value removes an element from the flow and positions it relative to the viewport?
- ASticky
- BFixed
- CAbsolute
- DRelative
4.A developer sets a modal to position: fixed but it scrolls with the page. What might be wrong?
- AThe modal's parent has position: absolute.
- BThe modal is missing a top or bottom threshold.
- CThe modal's parent has overflow: scroll.
- DThe modal is incorrectly set to position: relative.
5.A sidebar with position: sticky doesn't move when scrolling. What could be the cause?
- AThe sidebar lacks a z-index.
- BThe sidebar is inside a static container.
- CThe sidebar's parent is not tall enough.
- DThe sidebar is not absolutely positioned.
6.Why might an absolutely positioned tooltip be clipped unexpectedly?
- AThe tooltip is positioned relative to the viewport.
- BAn ancestor has overflow: hidden.
- CThe tooltip is inside a sticky container.
- DThe tooltip lacks a z-index.
7.A developer uses position: sticky on a navigation bar, but it doesn't stick. What might they have missed?
- ASetting a top threshold for the sticky behavior.
- BUsing position: absolute instead.
- CAdding a z-index to the navigation bar.
- DSetting overflow: visible on the parent.
8.What is the primary role of position: relative in a layout?
- ATo serve as a positioning ancestor for absolute elements.
- BTo remove the element from the document flow.
- CTo allow the element to scroll with its container.
- DTo fix the element to the viewport.