HTML Academy
Previous task
Flexbox, part 21/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
Features of the margin property
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Flex items and the block model

In the previous Flexbox chapter we were introduced to the basic concepts of this layout method, and we thoroughly explored how flex items are aligned. This chapter will be dedicated to learning how to control the sizes of flex items.

Let’s start with a simple question. How does our familiar block model work inside a flex container? Are there any differences in the behavior of the familiar properties?

The width, height, and internal margins and frames for flex containers and flex items work just as you would expect them to: the total size of items is determined by these components. This behavior can also be changed using the box-sizing property.

There are several important differences:

  • Flex items, in contrast to block elements, are not stretched to the entire width of the container by default.
  • The float property does not apply to flex items.

Now let’s work with the properties that we have already learned and make sure that they work in the usual way.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Flex items and the block model</title> <link href="course.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body class="world"> <div class="spot"> <div class="skate skate-1 racoon-green"></div> <div class="skate skate-2 racoon-brown"></div> <div class="skate skate-3 racoon-orange"></div> </div> </body> </html>
CSS
.spot { display: flex; align-items: center; justify-content: space-around; } .skate { min-width: 40px; min-height: 120px; border-color: white; border-top-left-radius: 75% 25%; border-top-right-radius: 75% 25%; border-bottom-right-radius: 75% 25%; border-bottom-left-radius: 75% 25%; background-clip: content-box; } .skate::after { left: 50%; margin-left: -10px; } .skate-2 { }

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
    1. Assign a width of 75px and a height of 300px (there is no need to change the minimum size) to all of the .skate skateboards on which the raccoons are sitting.
    2. And make the inner margins on all sides 10px.
    3. And then assign box-sizing: border-box to the second skateboard.

    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.