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

Summary

In this lesson, you've laid out the top of the shelter's home page and learned that:

  • Each value of display has its class: block, inline-block, inline, flex, grid. hidden is display: none: the element isn't shown and takes up no space.
  • flex makes a flex container. flex-row (the default) and flex-col set the direction of its main axis.
  • gap-* sets the gaps between flex items and grid cells, with the numbers of the spacing scale; gap-x-* and gap-y-* set them separately.
  • justify-* spreads the items along the main axis (justify-content): justify-start, justify-center, justify-end, justify-between, justify-around, justify-evenly.
  • items-* places them on the cross axis (align-items): items-stretch (the default), items-start, items-center, items-end, items-baseline.
  • flex-wrap moves the items that don't fit to the next line. grow and flex-1 make an item grow into the free space, and shrink-0 keeps it from getting narrower.
  • grid with grid-cols-* makes a grid of equally wide columns (repeat(2, minmax(0, 1fr))). col-span-*, col-span-full and row-span-* stretch an item over several cells.
  • To center items both ways, use flex items-center justify-center and a height, such as min-h-96. A single child can also be centered with grid place-items-center.
  • relative, absolute, fixed and sticky set position, and top-*, right-*, bottom-*, left-* and inset-* set the offsets. An absolute element is placed in its nearest ancestor with a position, usually one with relative.
  • sticky top-0 keeps a header at the top of the window, and z-* decides which element is on top.
  • As in the earlier lessons: when two classes set the same property, their order in the class attribute doesn't decide which one wins, so replace a class instead of adding a second one.

Your page now has its layout, but it doesn't react to the visitor yet. Next comes another small project: a gallery for a photo contest, with cards and a layout of its own. Then, in the lesson Hover, Focus and Other States, you'll make your page's buttons and links change when the mouse is over them or when they're clicked.

Before you go, a short exercise. We've added a footer at the bottom of the page, with three columns of information and a row with the copyright and a link back to the top. For now, everything in it is one below another.

Instructions

  1. 1

    Put the three columns of the footer side by side: add the classes grid grid-cols-3 and a gap, for example gap-6, to the div around them.

  2. 2

    In the last row of the footer, put the copyright on the left and the "Back to top" link on the right: add the classes flex justify-between to its div. Then, when you're ready, continue with the next lesson.

Back

11/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.