Bird
Raised Fist0
Tailwindmarkup~10 mins

Flex wrap behavior in Tailwind - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make the flex container wrap its items.

Tailwind
<div class="flex [1]">
  <div class="w-24 h-24 bg-blue-500"></div>
  <div class="w-24 h-24 bg-red-500"></div>
  <div class="w-24 h-24 bg-green-500"></div>
</div>
Drag options to blanks, or click blank then click option'
Aflex-wrap
Bflex-nowrap
Cflex-row
Dflex-col
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex-nowrap which prevents wrapping.
Using flex-row which controls direction, not wrapping.
2fill in blank
medium

Complete the code to prevent flex items from wrapping.

Tailwind
<section class="flex [1] gap-4">
  <div class="w-20 h-20 bg-yellow-400"></div>
  <div class="w-20 h-20 bg-purple-400"></div>
  <div class="w-20 h-20 bg-pink-400"></div>
</section>
Drag options to blanks, or click blank then click option'
Aflex-nowrap
Bflex-wrap-reverse
Cflex-wrap
Dflex-col
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex-wrap which allows wrapping.
Using flex-wrap-reverse which wraps but reverses the order.
3fill in blank
hard

Fix the error in the flex container class to make items wrap in reverse order.

Tailwind
<div class="flex [1]">
  <div class="w-16 h-16 bg-indigo-600"></div>
  <div class="w-16 h-16 bg-teal-600"></div>
  <div class="w-16 h-16 bg-orange-600"></div>
</div>
Drag options to blanks, or click blank then click option'
Aflex-nowrap
Bflex-row
Cflex-wrap
Dflex-wrap-reverse
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex-wrap which wraps but does not reverse.
Using flex-nowrap which prevents wrapping.
4fill in blank
hard

Fill both blanks to create a flex container that wraps items and arranges them in a column.

Tailwind
<div class="flex [1] [2] gap-2">
  <div class="w-20 h-10 bg-gray-700"></div>
  <div class="w-20 h-10 bg-gray-500"></div>
  <div class="w-20 h-10 bg-gray-300"></div>
</div>
Drag options to blanks, or click blank then click option'
Aflex-wrap
Bflex-nowrap
Cflex-col
Dflex-row
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex-nowrap which stops wrapping.
Using flex-row which arranges items horizontally.
5fill in blank
hard

Fill all three blanks to create a flex container that wraps items in reverse order and arranges them in a row.

Tailwind
<section class="flex [1] [2] [3] gap-3">
  <div class="w-16 h-16 bg-red-400"></div>
  <div class="w-16 h-16 bg-green-400"></div>
  <div class="w-16 h-16 bg-blue-400"></div>
</section>
Drag options to blanks, or click blank then click option'
Aflex-wrap
Bflex-wrap-reverse
Cflex-row
Dflex-col
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex-nowrap which prevents wrapping.
Using flex-col which arranges items vertically.

Practice

(1/5)
1. What does the Tailwind class flex-wrap do to flex items inside a container?
easy
A. Allows flex items to move to the next line when they don't fit in one row
B. Prevents flex items from wrapping and keeps them in one line
C. Reverses the order of flex items horizontally
D. Centers flex items vertically inside the container

Solution

  1. Step 1: Understand flex-wrap behavior

    The flex-wrap class in Tailwind allows flex items to wrap onto multiple lines if they don't fit in one row.
  2. Step 2: Compare with other options

    flex-nowrap prevents wrapping, flex-wrap-reverse wraps in reverse order, and centering is unrelated.
  3. Final Answer:

    Allows flex items to move to the next line when they don't fit in one row -> Option A
  4. Quick Check:

    flex-wrap = wrap items to next line [OK]
Hint: flex-wrap means items can jump to next line [OK]
Common Mistakes:
  • Confusing flex-wrap with flex-nowrap
  • Thinking flex-wrap reverses item order
  • Assuming flex-wrap centers items
2. Which Tailwind class correctly prevents flex items from wrapping onto multiple lines?
easy
A. flex-wrap
B. flex-center
C. flex-nowrap
D. flex-wrap-reverse

Solution

  1. Step 1: Identify the class that stops wrapping

    The class flex-nowrap keeps all flex items on a single line without wrapping.
  2. Step 2: Check other classes

    flex-wrap allows wrapping, flex-wrap-reverse wraps in reverse order, and flex-center is not a valid Tailwind class.
  3. Final Answer:

    flex-nowrap -> Option C
  4. Quick Check:

    nowrap means no wrapping [OK]
Hint: nowrap means no wrap, keep in one line [OK]
Common Mistakes:
  • Choosing flex-wrap instead of flex-nowrap
  • Confusing flex-wrap-reverse with nowrap
  • Using non-existent class flex-center
3. Given this HTML snippet with Tailwind classes:
<div class="flex flex-wrap">
  <div class="w-1/3">Box 1</div>
  <div class="w-1/3">Box 2</div>
  <div class="w-1/3">Box 3</div>
  <div class="w-1/3">Box 4</div>
</div>

How will the boxes be arranged on a wide screen?
medium
A. Three boxes in the first row, one box wrapped to second row
B. All four boxes in one row, each taking one third width
C. Two boxes per row, two rows total
D. Boxes stacked vertically in one column

Solution

  1. Step 1: Calculate total width per row

    Each box is set to width 1/3 (about 33.33%). Three boxes fit in one row (3 x 33.33% = 100%). The fourth box cannot fit in the same row.
  2. Step 2: Understand flex-wrap effect

    Because flex-wrap is used, the fourth box wraps to the next line, creating a second row with one box.
  3. Final Answer:

    Three boxes in the first row, one box wrapped to second row -> Option A
  4. Quick Check:

    flex-wrap + widths > 100% causes wrapping [OK]
Hint: Sum widths > 100% with flex-wrap means wrap next line [OK]
Common Mistakes:
  • Assuming all boxes fit in one row
  • Ignoring flex-wrap effect
  • Thinking boxes stack vertically without flex-wrap
4. You want flex items to wrap in reverse order (bottom to top). Which Tailwind class should you use? Your code currently uses flex-wrap but items wrap top to bottom.
medium
A. Replace flex-wrap with flex-nowrap
B. Add flex-wrap-reverse instead of flex-wrap
C. Add flex-row-reverse along with flex-wrap
D. Use flex-col instead of flex-wrap

Solution

  1. Step 1: Understand the difference between wrap classes

    flex-wrap wraps items normally (top to bottom). To wrap in reverse order (bottom to top), use flex-wrap-reverse.
  2. Step 2: Check other options

    flex-nowrap disables wrapping, flex-row-reverse reverses horizontal order but not wrap direction, flex-col changes flex direction vertically.
  3. Final Answer:

    Add flex-wrap-reverse instead of flex-wrap -> Option B
  4. Quick Check:

    flex-wrap-reverse reverses wrap direction [OK]
Hint: Use flex-wrap-reverse to wrap bottom to top [OK]
Common Mistakes:
  • Using flex-nowrap disables wrapping
  • Confusing flex-row-reverse with wrap direction
  • Replacing flex-wrap with flex-col changes layout direction
5. You have a flex container with flex-wrap and several items with fixed widths. On small screens, items overflow horizontally. How can you fix this using Tailwind classes?
hard
A. Set all items to fixed pixel widths to prevent wrapping
B. Replace flex-wrap with flex-nowrap to keep items in one line
C. Use responsive classes like sm:flex-nowrap and flex-wrap for smaller screens
D. Add overflow-x-auto to container to enable horizontal scroll

Solution

  1. Step 1: Identify overflow cause

    Fixed width items with flex-wrap can overflow container on small screens if total width exceeds viewport.
  2. Step 2: Apply horizontal scroll

    Adding overflow-x-auto on the container allows horizontal scrolling, preventing content cutoff without breaking layout.
  3. Final Answer:

    Add overflow-x-auto to container to enable horizontal scroll -> Option D
  4. Quick Check:

    overflow-x-auto fixes horizontal overflow [OK]
Hint: Use overflow-x-auto to scroll wide flex content [OK]
Common Mistakes:
  • Using flex-nowrap causes more overflow
  • Setting fixed pixel widths ignores responsiveness
  • Trying responsive nowrap incorrectly
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard