In this lesson, you gave the events banner room with min-height: 20rem and moved its heading and paragraph with flexbox’s alignment properties, watching them in DevTools’ flex overlay.
Key Points
justify-contentmoves flex items along the main axis. It shares out the space left over on that axis. When the items already fill the axis, as the heading and the paragraph fill the banner’s row, there’s nothing to share, and nothing moves. Where the row has room, as in the menu,centerputs half the leftover space before the items and half after.align-itemsmoves flex items across, on the cross axis. By default, it stretches every item to fill the container across: in a row, as tall as the container, margins included. (The Computed pane calls that defaultnormal, which stretches flex items.) Withcenter, the items shrink to their content’s height and sit in the middle.align-selfon one item takes the same values asalign-itemsand wins over it for that item.flex-endmeans the end of the axis: across a row, the bottom; across a column, the right side. The parent still does the arranging:align-selfasks the parent’s flex layout to place that one item differently, so withoutdisplay: flexon the parent, it does nothing.- A
min-heightof20rem(320 pixels) gives the banner height to move items in (the cross axis in a row, the main axis once it’s a column), and the banner can still grow if its text needs more space. flex-direction: columnturns the axes, so the two properties swap which way they move on screen. Watch out:justify-contentisn’t “horizontal” andalign-itemsisn’t “vertical”. They follow the axes.
Final Code
The end of events/layout.css: