justify-content positions items along the row. Three more properties finish the picture.
align-items
align-items positions items across the row, which for a normal row means up and down:
.bar {
display: flex;
align-items: center;
}
Use it when items in a row have different heights, such as a picture next to a line of text. Values include flex-start (top), center and flex-end (bottom).
Putting both together centers something in both directions, a job that was famously awkward before flexbox:
.box {
display: flex;
justify-content: center;
align-items: center;
}
flex-wrap
By default a flex container squeezes all of its items onto one row. With flex-wrap: wrap, items that do not fit move down to a new row:
.gallery {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
flex: 1
This one goes on an item, not the container. flex: 1 tells the item to grow and take up the leftover space. If several items have it, they share the space equally.
Your Task
- Make
.profilea flex container with agapof16px, and center its items vertically withalign-items. - Give
.infothe declarationflex: 1so it takes all the space left of the button. - Make
.tagsa flex container that wraps, with agapof8px.
.profileis a flex container with a16pxgap- The items in
.profileare centered vertically .infogrows to fill the leftover space.tagsis a flex container that wraps, with an8pxgap