HTML Academy
The item growth factor, flex-grow
Flexbox, part 28/28
Back to the list of tasks
  • 1. Flex items and the block model
  • 2. Features of the margin property
  • 3. Alignment and margins
  • 4. The flow direction of the main axis and margins
  • 5. The initial main size of flex item, flex-basis
  • 6. Test: Cubism
  • 7. The item growth factor, flex-grow
  • 8. Growing items proportionally
  • 9. Calculating the total size with flex-grow
  • 10. The item shrinkage factor, flex-shrink
  • 11. Shrinking items proportionally
  • 12. Calculating the total size with flex-shrink
  • 13. flex-shrink and min-width
  • 14. Test: Mastering factors
  • 15. The flex shorthand property
  • 16. Multi-line flex containers and flex-shrink
  • 17. Multi-line flex containers and flex-grow
  • 18. flex-basis: 100% and flex-wrap
  • 19. The heading with description in flexboxes
  • 20. Heading with description, part 2
  • 21. Flexible menu with overflowing content
  • 22. Flexible menu with overflow, part 2
  • 23. Input fields with dynamic width
  • 24. The course card
  • 25. Course card, part 2
  • 26. Course card, part 3
  • 27. So many cards
  • 28. Test: Flexible flows
Calculating the total size with flex-grow
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Growing items proportionally

If multiple flex items have a flex-grow value of more than zero, then they will share free space among themselves.

Free space will be added to flex items in proportion to the values of their “greed factor”. For example, if there are two items in a flex container:

.element-1 { flex-grow: 1; }
.element-2 { flex-grow: 2; }

Then the second item will be assigned twice as much free space as the first. If you change the values of the factors for these items to the following:

.element-1 { flex-grow: 50; }
.element-2 { flex-grow: 100; }

Then nothing will change, since factor ratio has not changed: 100 is two times 50. In other words, the value of the factor itself is not as important as its relationship with the factors for the other items.

This is a puzzle assignment for selecting proportions. You need to select the right values for flex-grow so that the total size of the items remain the same as for the bars below. You will recognize the basic sizes of the items and flex container sizes from the code.

Now experiment on your own, and in the next assignment we will analyze the algorithm for calculating the total size of flex items with a non-zero flex-grow value.

Hint: to achieve the simplest solution, you need factors that are integers of no more than 5.

Comments

  • index.html
  • style.css
HTML
1
2
<!DOCTYPE html>
<html lang="en">
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CSS
1
2
.spot {
display: flex;
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
GoalsCompleted 0 out of 2
    1. Assign the value flex-grow to the raccoons in the .spot-1 upper clearing so that their width is equal to the width of the bars.
    2. Do the same thing with the raccoons in the .spot-2 lower clearing.

    In this assignment you can only change the values of flex-grow,

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.