0
0
Tailwindmarkup~20 mins

Flex grow and shrink in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flexbox Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2: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?
AOnly the item with the highest flex-grow value gets all the extra space.
BAll items get equal extra space regardless of their flex-grow values.
CThe extra space is distributed inversely proportional to the flex-grow values.
DThe first item gets 1 part, the second 2 parts, and the third 3 parts of the extra space.
Attempts:
2 left
💡 Hint
Think of flex-grow as how many shares of extra space each item wants.
📝 Syntax
intermediate
1: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?
Aflex-shrink-0
Bshrink-0
Cflex-no-shrink
Dno-shrink
Attempts:
2 left
💡 Hint
Tailwind uses short class names for flex shrink and grow.
rendering
advanced
2: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:

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>
AItem 1 keeps its width, Item 2 shrinks, Item 3 shrinks.
BAll items shrink equally to fit 300px.
CItem 1 shrinks, Item 2 grows, Item 3 keeps width.
DItem 1 grows, Item 2 shrinks, Item 3 grows.
Attempts:
2 left
💡 Hint
Remember that shrink-0 prevents shrinking and flex-grow affects growing only.
selector
advanced
1:30remaining
Selecting the correct Tailwind class for flex-grow 2
Which Tailwind CSS class correctly sets flex-grow to 2 for an element?
Agrow-2
Bflex-grow-2
Cgrow-double
Dflex-grow-2x
Attempts:
2 left
💡 Hint
Tailwind uses short class names for grow values.
accessibility
expert
3: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?
AUse <span> elements with flex classes and no ARIA roles, relying on visual layout only.
BUse <div> elements only with flex classes and add tabindex="0" to each item.
CUse semantic <nav> and <ul> elements with <li> for items, and ensure focus styles are visible on flex items.
DUse <nav> with flex items but hide focus outlines to keep design clean.
Attempts:
2 left
💡 Hint
Think about semantic HTML and keyboard focus visibility.