Skip to main content
Module 7 · Lesson 3 of 427/60 in the course~22 min
Module lessons (3/4)

flex-grow, flex-shrink, flex-basis & min-width: 0

Lesson preview5 hands-on exercises readyModern HTML & CSS · Flexbox Layout in Depth

Calculate flexible width distribution cleanly and fix squished text/media inside flex items using min-width: 0.

What you'll learn in this lesson

  • Decode the three components of flex: grow shrink basis cleanly (flex: 1 vs flex: 0 1 auto vs flex: 0 0 220px).
  • Prevent squished sidebar thumbnails and clipped shrinking columns using flex-shrink: 0.
  • Cure the classic CSS puzzle: why long text or <code> inside flex: 1 refuses to wrap or shrink until you add min-width: 0!

Overview

Whenever you write flex on a flex child, CSS sets three numbers simultaneously:

Flex items default to min-width: auto (meaning _"never shrink narrower than my longest unbreakable word, <pre>, or <input>"_). Put a long URL inside a flex: 1 column and watch the column blow past your container right off the page!

Sections covered in this lesson

  1. 1What flex: 1 Really Means
  2. 2The Famous min-width: 0 Flexbox Bug
Pro Lesson · Flexbox Layout in Depth

Unlock "flex-grow, flex-shrink, flex-basis & min-width: 0" and the full Modern HTML & CSS curriculum

Calculate flexible width distribution cleanly and fix squished text/media inside flex items using min-width: 0.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.