Arranging Sibling Elements with Flexbox

suggest change

Use Flexbox—not floats—to arrange a one-dimensional row of sibling elements:

<div class="panels">
  <section>First panel</section>
  <section>Second panel</section>
</div>
.panels {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.panels > * {
  flex: 1 1 18rem;
  padding: 2rem;
}

Each panel can grow, shrink, and wrap when space is limited. Unlike a float-based layout, the container naturally includes the panels and gap creates spacing without margin bookkeeping.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents