0
0
Tailwindmarkup~20 mins

Z-index stacking control in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Z-Index Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the stacking order of elements with these Tailwind classes?

Consider three div elements with the following Tailwind CSS classes applied:

  • Element A: relative z-10
  • Element B: absolute z-20
  • Element C: fixed z-5

Which element will appear on top of the others?

AAll elements have the same stacking order because z-index only works with relative positioning.
BElement C appears on top because fixed positioning always stacks above relative and absolute.
CElement A appears on top because it has position relative and z-10.
DElement B appears on top because it has the highest z-index value (z-20).
Attempts:
2 left
💡 Hint

Remember that higher z-index values stack above lower ones regardless of position type, as long as position is set.

🧠 Conceptual
intermediate
2:00remaining
How does z-index behave with nested positioned elements in Tailwind?

Given a parent div with relative z-30 and a child div inside it with absolute z-40, which element will appear on top if another sibling div has relative z-35?

AThe sibling div with z-35 appears on top because parent's z-30 limits child's stacking context.
BAll elements stack equally because z-index does not work across different stacking contexts.
CThe parent div with z-30 appears on top because it is the ancestor of the child.
DThe child div with z-40 appears on top of the sibling with z-35 because 40 > 35.
Attempts:
2 left
💡 Hint

Think about how stacking contexts isolate z-index values inside them.

📝 Syntax
advanced
1:00remaining
Which Tailwind class correctly sets z-index to 50?

Choose the correct Tailwind CSS class to apply a z-index of 50 to an element.

Az-index-50
Bz-50
Cz50
Dz_index_50
Attempts:
2 left
💡 Hint

Tailwind uses a specific naming pattern for z-index utilities.

optimization
advanced
2:00remaining
How to optimize stacking order with minimal Tailwind classes?

You have three overlapping elements. You want Element X on top, Element Y in the middle, and Element Z at the bottom. Which set of Tailwind classes achieves this with the least code?

AElement X: <code>absolute z-10</code>, Element Y: <code>absolute z-20</code>, Element Z: <code>absolute z-30</code>
BElement X: <code>z-30</code>, Element Y: <code>z-20</code>, Element Z: <code>z-10</code>
CElement X: <code>relative z-30</code>, Element Y: <code>relative z-20</code>, Element Z: <code>relative z-10</code>
DElement X: <code>relative z-10</code>, Element Y: <code>relative z-20</code>, Element Z: <code>relative z-30</code>
Attempts:
2 left
💡 Hint

Remember z-index only works on positioned elements.

🔧 Debug
expert
3:00remaining
Why does z-index not work on this Tailwind element?

An element has the class z-40 but it is still appearing behind other elements with lower z-index values. What is the most likely reason?

AThe element does not have a position class like <code>relative</code>, <code>absolute</code>, or <code>fixed</code>.
BThe z-40 class is overridden by a later CSS rule with higher specificity.
CTailwind's z-40 class only works inside flex containers.
DThe browser does not support z-index values above 30.
Attempts:
2 left
💡 Hint

Check if the element is positioned.