- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Alignment of flex container lines, align-content</title>
<link href="course.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body class="house">
<div class="room room-1">
<div class="rug simba"></div>
<div class="rug rudolf"></div>
<div class="rug muffin"></div>
<div class="rug massimo"></div>
</div>
<div class="room room-2">
<div class="rug simba"></div>
<div class="rug rudolf"></div>
<div class="rug muffin"></div>
<div class="rug massimo"></div>
</div>
</body>
</html>
CSS
.room {
display: flex;
flex-wrap: wrap;
height: 150px;
}
.rug {
min-height: 20px;
width: 80px;
}
.room-1 {
align-content: stretch;
align-items: flex-end;
}
.room-2 {
align-content: stretch;
align-items: flex-start;
}
You’ve gone to a different page
Goalscompleted
0
- For
.room-1
setalign-content
to the start of the cross axis, - and for
.room-2
setalign-content
to the end of the cross axis. - Then increase the width of the rug (
.rug
) to120px
so that there are two rows of items in the blocks.
See how the alignment of the rows takes precedence over the alignment of the items.
Comments