Challenge - 5 Problems
Flexbox Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding flex-grow behavior
Given three flex items inside a container with
flex-grow values of 1, 2, and 3 respectively, how will the extra space be distributed among them?Attempts:
2 left
💡 Hint
Think of flex-grow as how many shares of extra space each item wants.
✗ Incorrect
The flex-grow property defines how much of the available space inside the container each item should take. The space is divided proportionally based on the flex-grow values.
📝 Syntax
intermediate1:30remaining
Correct Tailwind class for flex-shrink
Which Tailwind CSS class correctly sets an element's
flex-shrink property to 0, preventing it from shrinking?Attempts:
2 left
💡 Hint
Tailwind uses short class names for flex shrink and grow.
✗ Incorrect
In Tailwind CSS, shrink-0 sets flex-shrink: 0;. The prefix flex- is not used for shrink classes.
❓ rendering
advanced2:30remaining
Visual effect of flex-grow and flex-shrink combined
You have a flex container with fixed width 600px and three items inside. The items have these Tailwind classes:
What will happen when the container width shrinks to 300px?
grow-0 shrink-0 w-40, grow shrink w-40, and grow-0 shrink w-40 respectively.What will happen when the container width shrinks to 300px?
Tailwind
<div class="flex w-[600px] border border-gray-400"> <div class="grow-0 shrink-0 w-40 bg-red-300">Item 1</div> <div class="grow shrink w-40 bg-green-300">Item 2</div> <div class="grow-0 shrink w-40 bg-blue-300">Item 3</div> </div>
Attempts:
2 left
💡 Hint
Remember that
shrink-0 prevents shrinking and flex-grow affects growing only.✗ Incorrect
Item 1 has shrink-0 so it keeps its width. Item 2 and 3 can shrink, so they reduce width to fit the smaller container.
❓ selector
advanced1:30remaining
Selecting the correct Tailwind class for flex-grow 2
Which Tailwind CSS class correctly sets
flex-grow to 2 for an element?Attempts:
2 left
💡 Hint
Tailwind uses short class names for grow values.
✗ Incorrect
grow-2 sets flex-grow: 2; in Tailwind CSS. The prefix flex-grow- is not used.
❓ accessibility
expert3:00remaining
Ensuring accessible flexbox layout with dynamic grow and shrink
You have a navigation bar with flex items that grow and shrink dynamically. What is the best practice to ensure keyboard users can navigate the items easily and screen readers understand the structure?
Attempts:
2 left
💡 Hint
Think about semantic HTML and keyboard focus visibility.
✗ Incorrect
Using semantic elements like <nav> and lists helps screen readers understand navigation. Visible focus styles help keyboard users see where they are.