Bird
Raised Fist0
Tailwindmarkup~10 mins

Flex basis and sizing in Tailwind - Browser Rendering Trace

Choose your learning style10 modes available
Render Flow - Flex basis and sizing
[Parse Tailwind classes] -> [Identify flex container] -> [Apply flex-basis from class] -> [Calculate item size] -> [Layout flex items] -> [Paint items] -> [Composite]
The browser reads Tailwind classes, applies flex-basis sizing to flex items, calculates their size based on flex rules, then lays out and paints them on screen.
Render Steps - 4 Steps
Code Added:<div class="flex"> container
Before
[ ]
(empty container, no children)
→
After
[__________________________]
(empty flex container, horizontal line)
Adding the flex container sets display:flex, creating a horizontal layout context.
🔧 Browser Action:Creates flex formatting context
Code Sample
A flex container with three boxes sized differently using flex-basis and flex-grow/shrink from Tailwind classes.
Tailwind
<div class="flex">
  <div class="flex-none w-24 bg-blue-500">Box 1</div>
  <div class="flex-auto bg-green-500">Box 2</div>
  <div class="flex-initial w-32 bg-red-500">Box 3</div>
</div>
Tailwind
/* Tailwind classes translate to: */
.flex { display: flex; }
.flex-none { flex: none; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.w-24 { width: 6rem; }
.w-32 { width: 8rem; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-green-500 { background-color: #22c55e; }
.bg-red-500 { background-color: #ef4444; }
Render Quiz - 3 Questions
Test your understanding
After step 3, how does Box 2 behave visually inside the flex container?
AIt grows to fill leftover space after Box 1
BIt stays fixed size and does not grow
CIt shrinks smaller than its content
DIt disappears from the layout
Common Confusions - 3 Topics
Why does a flex-none item not grow even if there is space?
Because flex-none sets flex-grow to 0, the item keeps its fixed size and does not expand to fill space (see step 2).
💡 flex-grow:0 means no growing; item size stays fixed.
Why can flex-initial items shrink but not grow?
flex-initial sets flex-grow to 0 and flex-shrink to 1, so the item keeps its base size but can shrink if container is too small (see step 4).
💡 flex-shrink:1 allows shrinking; flex-grow:0 prevents growing.
What happens if no width is set on flex-auto item?
The flex-auto item uses flex-basis:auto, so it sizes based on content but can grow to fill leftover space (see step 3).
💡 flex-auto grows to fill space, width optional.
Property Reference
PropertyTailwind ClassDefault ValueVisual EffectCommon Use
flex-basisw-24, w-32, etc.autoSets initial size of flex itemControl fixed or minimum size
flex-growflex-auto (grow=1), flex-none (grow=0)0Allows item to grow to fill spaceFlexible layouts
flex-shrinkflex-initial (shrink=1), flex-none (shrink=0)1Allows item to shrink if neededPrevent overflow or keep size
flexflex-none, flex-auto, flex-initialflex: 0 1 autoShorthand for grow, shrink, basisQuick flex sizing
Concept Snapshot
flex-basis sets the starting size of a flex item. flex-grow controls if the item can expand to fill space. flex-shrink controls if the item can shrink when needed. Tailwind classes like flex-none, flex-auto, flex-initial combine these. Width classes (w-24, w-32) set fixed sizes used as flex-basis. Together they control how flex items size and fill the container.

Practice

(1/5)
1. What does the Tailwind class basis-1/3 do in a flex container?
easy
A. Makes the flex item grow to fill one-third of the container
B. Sets the initial size of the flex item to one-third of the container's main size
C. Prevents the flex item from shrinking below one-third of its size
D. Sets the flex item to always be exactly one-third of the container width regardless of content

Solution

  1. Step 1: Understand flex basis meaning

    Flex basis sets the starting size of a flex item before growing or shrinking.
  2. Step 2: Interpret basis-1/3 in Tailwind

    This class sets the flex basis to one-third of the container's main size, not forcing exact size but initial size.
  3. Final Answer:

    Sets the initial size of the flex item to one-third of the container's main size -> Option B
  4. Quick Check:

    Flex basis = initial size = one-third [OK]
Hint: Flex basis sets start size, not final size [OK]
Common Mistakes:
  • Confusing basis with grow or shrink
  • Thinking basis fixes size exactly
  • Assuming basis prevents shrinking
2. Which of the following is the correct Tailwind class to set a flex item's basis to 16rem?
easy
A. basis-16rem
B. basis-64rem
C. basis-16
D. basis-64

Solution

  1. Step 1: Recall Tailwind sizing scale

    Tailwind uses numeric scale where 64 equals 16rem (4rem * 16).
  2. Step 2: Match class syntax

    The correct class is basis-64 to set basis to 16rem, no 'rem' suffix used.
  3. Final Answer:

    basis-64 -> Option D
  4. Quick Check:

    basis-64 = 16rem in Tailwind [OK]
Hint: Tailwind uses numbers, not units, for spacing [OK]
Common Mistakes:
  • Adding 'rem' suffix in class name
  • Using wrong numeric scale
  • Confusing basis with width classes
3. Given this HTML snippet:
<div class="flex w-96">
  <div class="basis-1/4 bg-blue-500">Box 1</div>
  <div class="basis-1/2 bg-red-500">Box 2</div>
  <div class="basis-1/4 bg-green-500">Box 3</div>
</div>

What will be the width of Box 2 inside the 24rem wide container?
medium
A. 6rem
B. 24rem
C. 12rem
D. 18rem

Solution

  1. Step 1: Calculate container width in rem

    The container width is 24rem (w-96 means 24rem).
  2. Step 2: Calculate Box 2 basis size

    Box 2 has basis-1/2, so initial size is half of 24rem = 12rem.
  3. Final Answer:

    12rem -> Option C
  4. Quick Check:

    Half of 24rem = 12rem [OK]
Hint: Multiply container width by basis fraction [OK]
Common Mistakes:
  • Confusing basis fraction with grow factor
  • Using container width in px instead of rem
  • Adding basis sizes instead of calculating individually
4. You wrote this Tailwind code:
<div class="flex">
  <div class="basis-2/3">Item 1</div>
  <div class="basis-1/2">Item 2</div>
</div>

But the items overflow the container width. What is the main reason?
medium
A. The sum of basis sizes (2/3 + 1/2) exceeds 1, causing overflow
B. Missing flex-grow classes to allow shrinking
C. Tailwind does not support fractional basis classes
D. The container needs flex-wrap to prevent overflow

Solution

  1. Step 1: Calculate the sum of basis fractions

    2/3 + 1/2 = 4/6 + 3/6 = 7/6 > 1.
  2. Step 2: Understand the effect

    When the sum of flex-basis values exceeds 1, it causes the flex items to overflow the container.
  3. Final Answer:

    The sum of basis sizes (2/3 + 1/2) exceeds 1, causing overflow -> Option A
  4. Quick Check:

    Sum of basis fractions > 1 causes overflow [OK]
Hint: Check if basis fractions sum over 1 for overflow [OK]
Common Mistakes:
  • Assuming basis fractions always fit container
  • Ignoring default flex shrink behavior
  • Confusing grow with shrink effects
5. You want three flex items inside a container to have these widths initially: 25%, 50%, and 25%. You also want the middle item to grow twice as fast as the others when space is available. Which Tailwind classes correctly achieve this?
hard
A. basis-1/4 grow, basis-1/2 [flex-grow:2], basis-1/4 grow
B. basis-1/4 flex-grow-1, basis-1/2 flex-grow-2, basis-1/4 flex-grow-1
C. basis-1/4 grow, basis-1/2 grow [flex-grow:2], basis-1/4 grow
D. basis-1/4 grow, basis-1/2 grow, basis-1/4 grow

Solution

  1. Step 1: Set correct basis classes

    Use basis-1/4 for 25% and basis-1/2 for 50% widths.
  2. Step 2: Apply grow classes

    Tailwind uses grow for flex-grow:1 and [flex-grow:2] for flex-grow:2.
  3. Step 3: Assign grow classes to items

    First and third items get grow, middle item gets [flex-grow:2] to grow twice as fast.
  4. Final Answer:

    basis-1/4 grow, basis-1/2 [flex-grow:2], basis-1/4 grow -> Option A
  5. Quick Check:

    Use grow and [flex-grow:2] with basis fractions [OK]
Hint: Use grow and [flex-grow:2] classes for different grow rates [OK]
Common Mistakes:
  • Using non-existent flex-grow-1 class
  • Combining grow and grow-2 on same element
  • Forgetting to set basis sizes
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