liveBook · Manning

Flex

As explained in Web Design Playground, Second Edition

The CSS flex property is a shorthand for setting an item’s flex-grow, flex-shrink, and flex-basis values.

The CSS flex property is a compact way to set an item’s flex-grow, flex-shrink, and flex-basis values. Think of it as the three-question form for a Flexbox item: may it grow, may it shrink, and what size should it start with? section 12.4

Write the shorthand in several useful forms:

PLAY

Try familiar shorthand combinations: flex: 0 1 auto; flex: 1 0; and flex: 0 0 10em;. Each example sets the item’s flexibility using fewer declarations—CSS doing a little word-saving magic. section 12.4

item {
    flex: flex-grow flex-shrink flex-basis;
    flex: flex-grow flex-shrink;
    flex: flex-grow flex-basis;
    flex: flex-grow;
    flex: flex-basis;
}

Use the syntax listing to compare the complete and abbreviated flex forms at a glance. section 12.4

How Web Design Playground, Second Edition covers it

How deep it goes
Defines complete and abbreviated syntax with examples, but stops short of detailing each component’s full behavior.
Examples
Shows flex: 0 1 auto;, flex: 1 0;, and flex: 0 0 10em; as shorthand examples.
What it assumes
Assumes familiarity with Flexbox containers and items while introducing the item-sizing questions from the basics.
What you can do after
Apply via CSS shorthand to configure a Flexbox item’s growth, shrinkage, and starting size.
How it connects
Connects flex-grow, flex-shrink, flex-basis, Flexbox items, and Flexbox containers.

Also explained in

Compare how 3 books explain flex →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.