Flex-wrap

In this lesson, we will create a Flexbox-based grid with multiple rows or columns using flex-wrap. We will learn why wrapping is beneficial when creating a list of blog posts or a list of images.

Challenges with creating multiline grid structure

When creating a gallery of images or a landing page displaying thumbnails of blog posts, it is a natural phenomenon that we prefer styling each image or post in a container, regardless of whether they are displayed in one line or multiple lines.

The following markup is not intuitive:

<div class="container">
  <div class="row">
    <div class="blogpost">Post 1</div>
    <div class="blogpost">Post 2</div>    
    <div class="blogpost">Post 3</div>
  </div>
  <div
...