liveBook · Manning

Shrink

Flex shrinking is the Flexbox behavior that reduces flex-item sizes and distributes insufficient space according to shrink factors and size constraints.

How 4 Manning books explain it

Web Design Playground

A flexbox sizing behavior that determines how a flex item reduces in size when space is limited.

How it is used
Controls how flex items give up space when they do not fit their container.
How deep it goes
Explains default and custom values, initial-width effects, and content minimums without working through the shrinkage math.
Examples
Uses a thumbnail-and-text list and a header logo that must not shrink.
What you can do after
Build it from scratch: create a flexbox thumbnail list whose image does not shrink while its text uses remaining space.

Read how Web Design Playground explains shrink →

Math for Web Design

The flex shrinking algorithm is the Flexbox procedure for distributing negative free space among shrinkable flex items according to their flex-shrink factors and size constraints.

How it is used
Distributes a flex container’s width shortage among items whose starting sizes do not fit.
How deep it goes
Works through weighted factors, overflow shares, final widths, and redistribution after a minimum-width constraint.
Examples
Calculates three 450px items inside 600px and applies a 100px minimum width; also sizes buttons in a toolbar.
What you can do after
Diagnose/debug with it when flex items shrink unequally, hit minimum widths, or shrink despite an earlier property setting.

Read how Math for Web Design explains shrink →

Web Design Playground, Second Edition

The CSS flex-shrink property specifies how much a flex item may contract relative to the other flex items when insufficient space is available.

How it is used
Controls how flex items contract when they lack room in their container.
How deep it goes
Explains default and relative values, initial-width effects, and a content-size limit, but defers the shrinkage calculations.
Examples
Uses differently sized flex items and a thumbnail list whose image does not shrink beside growing text.
What you can do after
Operate/configure it with CSS values to control which flex items shrink and which retain their size.

Read how Web Design Playground, Second Edition explains shrink →

CSS in Depth, Second Edition

The CSS flex-shrink property specifies a flex item's shrink factor when the flex items' initial sizes exceed the available space in the flex container.

How it is used
Prevents flex layouts from overflowing when initial item sizes exceed the container’s available main-axis space.
How deep it goes
Explains zero and positive factors, proportional contraction, initial-size effects, gaps, padding, and column-direction constraints.
Examples
Demonstrates two percentage-based columns separated by a gap and nested tiles in a vertical flexbox.
What you can do after
Build it from scratch by choosing shrink factors for columns and predicting when constrained flex items will contract.

Read how CSS in Depth, Second Edition explains shrink →

Also covered in

What to know first

Related concepts

Questions about shrink

What is shrink?

Flex shrinking is the Flexbox behavior that reduces flex-item sizes and distributes insufficient space according to shrink factors and size constraints.

Which Manning books explain shrink?

Web Design Playground, Math for Web Design, Web Design Playground, Second Edition and CSS in Depth, Second Edition.

What should I know before learning shrink?

Manning books that teach shrink usually introduce flex container, width, flexbox and main axis first.

What is shrink a kind of?

Shrink is a kind of flex factor. A flex factor is either a flex-grow or flex-shrink value that controls an item's participation in Flexbox space distribution.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.