</> Code Corner

CSS · CSS Flexbox · Lesson 59

CSS Flexbox

One-dimensional layouts with flex containers.

The Flexible Box Layout Module makes it easy to design flexible responsive layouts without float or positioning. A flex container is created with display: flex; its children become flex items.

Example

<style>
.flex-container { display: flex; background-color: DodgerBlue; padding: 6px; }
.flex-container > div { background-color: #f1f1f1; margin: 6px; padding: 20px; font-size: 24px; }
</style>
<div class="flex-container">
  <div>1</div><div>2</div><div>3</div>
</div>
Tip: Flexbox is one-dimensional: it lays items out in a row OR a column. For two-dimensional layouts use CSS Grid.

Keep reading “CSS Flexbox”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋