0
0
CSSmarkup~20 mins

Position fixed and sticky in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Position Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding position: fixed behavior
What happens to an element with position: fixed when you scroll the page?
AIt stays in the same place relative to the viewport, not moving when scrolling.
BIt scrolls with the page content like a normal element.
CIt moves only horizontally but not vertically when scrolling.
DIt disappears when you scroll past its original position.
Attempts:
2 left
💡 Hint
Think about a sticky note stuck to your computer screen that never moves when you scroll.
🧠 Conceptual
intermediate
2:00remaining
How position: sticky works
Which statement best describes how position: sticky behaves?
AIt disappears when scrolling past its container.
BIt behaves like <code>relative</code> until a scroll threshold, then it sticks to a position.
CIt behaves like <code>absolute</code> and moves with the nearest positioned ancestor.
DIt behaves like <code>fixed</code> all the time, ignoring scroll position.
Attempts:
2 left
💡 Hint
Imagine a header that scrolls up but then sticks at the top of the page.
📝 Syntax
advanced
2:00remaining
CSS for sticky header with top offset
Which CSS snippet correctly makes a header sticky at 0 distance from the top of the viewport?
CSS
header {
  /* Your CSS here */
}
Aposition: relative; top: 0;
Bposition: fixed; top: 0;
Cposition: absolute; top: 0;
Dposition: sticky; top: 0;
Attempts:
2 left
💡 Hint
Sticky means it scrolls until it reaches the top, then stays there.
rendering
advanced
2:00remaining
Visual effect of fixed vs sticky
You have two boxes: one with position: fixed; top: 10px; and another with position: sticky; top: 10px;. What will you see when you scroll down the page?
AThe sticky box stays fixed at 10px from top always; the fixed box scrolls normally.
BBoth boxes scroll normally and disappear when out of view.
CThe fixed box stays visible at 10px from top always; the sticky box scrolls until 10px from top then sticks.
DBoth boxes disappear when scrolling past their original position.
Attempts:
2 left
💡 Hint
Think about which box behaves like glued to the screen and which one only sticks after scrolling.
accessibility
expert
3:00remaining
Accessibility considerations for fixed and sticky elements
Which accessibility best practice should you follow when using position: fixed or position: sticky for navigation bars?
AEnsure keyboard focus can reach all interactive elements and that fixed/sticky bars do not cover content.
BUse fixed or sticky positioning without any additional ARIA roles or focus management.
CHide fixed or sticky elements from assistive technologies to reduce clutter.
DAvoid using fixed or sticky positioning because screen readers cannot read them.
Attempts:
2 left
💡 Hint
Think about users who navigate with keyboard or screen readers and how fixed bars might block content.