0
0
Tailwindmarkup~20 mins

Position utilities (relative, absolute, fixed) in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Positioning Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Tailwind's relative positioning
What happens when you apply relative class to a container in Tailwind CSS?
AThe element is removed from the document flow and positioned relative to the viewport.
BThe element becomes invisible but still takes up space.
CThe element is fixed in place and does not move when scrolling.
DThe element is positioned relative to its normal position, allowing <code>top</code>, <code>left</code>, <code>right</code>, and <code>bottom</code> to offset it.
Attempts:
2 left
💡 Hint
Think about how relative positioning shifts an element from where it normally sits.
📝 Syntax
intermediate
2:00remaining
Which Tailwind class correctly fixes an element to the top of the viewport?
Select the Tailwind class combination that fixes an element at the top of the viewport and spans full width.
Afixed top-0 left-0 w-full
Babsolute top-0 left-0 w-full
Crelative top-0 left-0 w-full
Dsticky top-0 left-0 w-full
Attempts:
2 left
💡 Hint
Fixed position means the element stays visible even when scrolling.
rendering
advanced
3:00remaining
Visual result of nested absolute positioning
Given this HTML and Tailwind CSS, what will you see in the browser?

<div class="relative w-64 h-64 bg-blue-200">
  <div class="absolute top-4 left-4 w-32 h-32 bg-red-400"></div>
</div>
Tailwind
<div class="relative w-64 h-64 bg-blue-200">
  <div class="absolute top-4 left-4 w-32 h-32 bg-red-400"></div>
</div>
AA blue square 16rem by 16rem with a smaller red square 8rem by 8rem inside, offset 1rem from top-left corner.
BA red square 8rem by 8rem with a smaller blue square inside it.
CTwo overlapping blue squares with no red visible.
DOnly a red square visible, filling the entire viewport.
Attempts:
2 left
💡 Hint
Remember that absolute positions relative to the nearest relative ancestor.
selector
advanced
2:00remaining
Which Tailwind class combination causes an element to scroll with the page but stay visible at the top after scrolling past it?
Choose the correct Tailwind classes to make an element stick to the top of the viewport only after scrolling past it.
Aabsolute top-0
Bsticky top-0
Cfixed top-0
Drelative top-0
Attempts:
2 left
💡 Hint
Sticky positioning acts like relative until a scroll threshold is passed.
accessibility
expert
3:00remaining
Accessibility concern with fixed positioned elements
When using fixed positioning in Tailwind to create a navigation bar, which accessibility issue should you be most careful about?
AAvoiding use of <code>aria-label</code> on fixed elements because it confuses screen readers.
BMaking sure the fixed element uses <code>z-index: 0</code> to stay behind all content.
CEnsuring the fixed element does not cover important content and is keyboard accessible.
DUsing fixed positioning only on images, never on interactive elements.
Attempts:
2 left
💡 Hint
Think about how fixed elements can block content and affect keyboard users.