</> Code Corner

CSS · CSS Flexbox · Lesson 60

CSS Flex Container

flex-direction, wrap, justify-content and align-items.

The flex container properties control how items are laid out.

Example

<style>
.c { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; height: 160px; background: #1e90ff; padding: 10px; }
.c div { background: #f1f1f1; width: 90px; padding: 15px; text-align: center; }
.c div:nth-child(2) { padding: 35px 15px; }
</style>
<div class="c"><div>1</div><div>2</div><div>3</div><div>4</div></div>
Property Values
flex-direction row, row-reverse, column, column-reverse
flex-wrap nowrap, wrap, wrap-reverse
justify-content flex-start, center, flex-end, space-between, space-around, space-evenly
align-items stretch, center, flex-start, flex-end, baseline
align-content Aligns wrapped lines
gap Space between items

Keep reading “CSS Flex Container”

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

Chat with us 👋