Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Justify and Align

The navigation itself has three visible children: the logo, the list of links and the Donate button. (The hidden Menu button doesn't count: an element with display: none isn't laid out at all.) Let's put them in a row, with the logo on the left and the button on the right.

As you know from the CSS course, the items are spread along the main axis by the property justify-content and placed on the cross axis by align-items. Their values have classes too: justify-* for justify-content and items-* for align-items. The names are shorter than the values, because Tailwind leaves out the words flex- and space-:

ClassCSS
justify-startjustify-content: flex-start;
justify-centerjustify-content: center;
justify-endjustify-content: flex-end;
justify-betweenjustify-content: space-between;
justify-aroundjustify-content: space-around;
justify-evenlyjustify-content: space-evenly;
items-stretchalign-items: stretch;
items-startalign-items: flex-start;
items-centeralign-items: center;
items-endalign-items: flex-end;
items-baselinealign-items: baseline;

Without these classes, a flex container behaves as with justify-start and items-stretch, just like in CSS.

Instructions

  1. 1

    Add the class flex to the nav element. The logo, the links and the Donate button stand side by side. And the button's padding now takes up space: as a flex item, the link is laid out as a block.

  2. 2

    Add the class justify-between. The logo stays on the left, the button moves to the right edge, and the links are in between, with the same space on both sides.

  3. 3

    The logo, the links and the button are stretched to the height of the tallest of them, the button, and their text stays at the top. That's why the links sit a bit higher than the text of the button. Add the class items-center, and everything is centered vertically.

Back

3/11

  1. 1. Display
  2. 2. Flexbox
  3. 3. Justify and Align
  4. 4. Columns
  5. 5. Wrapping and Growing
  6. 6. Grid
  7. 7. Spanning Columns
  8. 8. Centering
  9. 9. Badges on Cards
  10. 10. A Sticky Header
  11. 11. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.