HTML Academy
The display: flex property, flex item
Flexbox, part 12/32
Back to the list of tasks
  • 1. The display: flex property, flex item
  • 2. The flex-direction property, main axis
  • 3. The flexbox cross axis
  • 4. The justify-content property, alignment along the main axis
  • 5. The justify-content property: flex-start | flex-end
  • 6. The justify-content property: space-between | space-around
  • 7. The align-items property, alignment along the cross axis
  • 8. The align-items property: flex-start | flex-end
  • 9. The align-items: baseline property
  • 10. The align-self property, or selfish alignment
  • 11. The align-self: baseline property
  • 12. Test: Creating a simple palette
  • 13. The flex-wrap property, overflow of flex items
  • 14. The flex-wrap property, reverse overflow
  • 15. The align-content property, alignment of flex container lines
  • 16. The align-content property: stretch and align-items
  • 17. The align-content property: non-stretch and align-items
  • 18. The align-content property, remaining values
  • 19. The order property, the sequence number of the flex item
  • 20. Test: Creating a more complicated palette
  • 21. Perfect centering by assigning margin: auto to the flex container
  • 22. Perfect centering, flex alignment
  • 23. The adaptive horizontal menu, part 1
  • 24. The adaptive horizontal menu, part 2
  • 25. The adaptive horizontal menu, part 3
  • 26. The vertical row of icons
  • 27. The vertical row of icons, part 2
  • 28. The vertical row of icons, part 3
  • 29. Ordering elements with CSS
  • 30. Vertically aligning blocks using a flexbox
  • 31. Test: Complex palettes
  • 32. Summary of “Flexbox, Part 1”
The flexbox cross axis
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The flex-direction property, main axis

Do you remember how a document normally flows? Blocks and text are arranged from left to right and from top to bottom.

Under the traditional block model, the directions “left”, “right”, “top”, and “bottom” cannot be changed. But within a flex container you can modify these concepts, since you can change the typical direction of the flow.

The flexbox uses the concept of the “main axis” instead of the simple directions “left” and “right”. The flex items flow along the main axis from the start to the end of it.

The flex elements "flow" along the main axis

By default, the main axis flows from left to right, but it can be rotated in all directions using the flex-direction property, which is assigned for the flex container. The property values are:

  • row – The default value, whereby the main axis flows from left to right.

  • column — The main axis flows from top to bottom.

  • row-reverse — The main axis flows from right to left.

  • column-reverse — The main axis flows from bottom to top.

Flex items are always arranged along the main axis, regardless of the direction of flow.

We added a main axis indicator to the mini browser. Now you will always know its direction of flow.

Comments

  • index.html
  • style.css
HTML
1
2
<!DOCTYPE html>
<html lang="en">
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CSS
1
2
.room {
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 3

    Assign the following directions to the main axis for the .room block:

    1. from right to left,
    2. from top to bottom,
    3. and then from bottom to top.

    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.