Flex item sizing, online

Six activities your students do on their own devices. See who's finished, and their scores.

Flex item sizing in one minute

What students need to know

A flex-shrink value of 0 locks the item's minimum baseline size to its flex-basis value. flex-grow: 1 is the standard mechanism to distribute leftover space equally among expanding elements.

flex-grow accepts unitless numbers as factors, never length units like px. Higher values mean a larger share of the remaining available space will be allocated.

Mistakes students make

  • The flex-basis property must be placed inside a CSS rule block, not floating outside.
  • Numerical values for flex-basis require a unit like px, %, or the keyword auto.
  • The flex-grow property accepts a unitless number factor, not a keyword like 'yes'.
  • The flex-shrink property accepts only non-negative numbers; negative values are invalid.

Discover other journeys with this module

What students will learn in this module

Every question in Module 55

Quick questions

  1. Which property sets the default initial size of a flex item before space distribution?Aflex-growBflex-basis
  2. What is the correct syntax to prevent a flex item from shrinking when container space is tight?Aflex-shrink: false;Bflex-shrink: 0;
  3. Which of these is a valid value for the flex-grow property?A2B200px
  4. If two flex items have flex-grow values of 1 and 2, which one absorbs more leftover space?AThe item with flex-grow: 2BThe item with flex-grow: 1
  5. What is the initial default value of the flex-shrink property on flex items?A1B0

Key terms

Students type the meaning of:

  • flex-basis

Match the pairs

.item {
  flex-basis: 300px;
}
Match it to what it does
.item {
  flex-grow: 2;
}
Match it to what it does
Ensures a flex item maintains its size and never shrinks down.Match it to what it does
Sets the item to fill space relative to others dynamically.Match it to what it does
.item {
  flex-basis: 40;
}
Match it to what it does
.item {
  flex-grow: 10px;
}
Match it to what it does

Fill in the blanks

  1. .card {
      __________: 250px;
    }

    Hint: Type the property that sets the initial main size of a flex item

  2. .sidebar {
      _________: 1;
    }

    Hint: Type the property that defines the ability for a flex item to grow

  3. .box {
      ___________: 0;
    }

    Hint: Type the property that prevents a flex item from shrinking

  4. .item {
      flex-basis: ____;
    }

    Hint: Type the default value for the flex-basis property

  5. .panel {
      flex-grow: _;
    }

    Hint: Type a positive number value to make this item grow twice as much as others

Spot the error

Question 1

Aflex-basis: 100px;B.item {C  color: blue;D}

Question 2

A.item {B  flex-basis: 200;C  color: red;D}

Question 3

A.box {B  display: flex;C  flex-grow: yes;D}

Question 4

A.panel {B  display: block;C  width: 100%;D  flex-shrink: -1;E}

Question 5

A  flex-size: 300px;B.sidebar {C  display: flex;D}