Summary
In this lesson, you've laid out the top of the shelter's home page and learned that:
- Each value of
displayhas its class:block,inline-block,inline,flex,grid.hiddenisdisplay: none: the element isn't shown and takes up no space. flexmakes a flex container.flex-row(the default) andflex-colset 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-*andgap-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-wrapmoves the items that don't fit to the next line.growandflex-1make an item grow into the free space, andshrink-0keeps it from getting narrower.gridwithgrid-cols-*makes a grid of equally wide columns (repeat(2, minmax(0, 1fr))).col-span-*,col-span-fullandrow-span-*stretch an item over several cells.- To center items both ways, use
flex items-center justify-centerand a height, such asmin-h-96. A single child can also be centered withgrid place-items-center. relative,absolute,fixedandstickysetposition, andtop-*,right-*,bottom-*,left-*andinset-*set the offsets. An absolute element is placed in its nearest ancestor with a position, usually one withrelative.sticky top-0keeps a header at the top of the window, andz-*decides which element is on top.- As in the earlier lessons: when two classes set the same property, their order in the
classattribute 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. In the next lesson, Hover, Focus and Other States, you'll make its 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
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.
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.
Start programming for free
11/11