Menu
Coddy logo textTech

justify-content

Lesson 7 of 15 in Coddy's CSS Flexbox - The Complete Course course.

The justify-content property defines the alignment along the main axis.

The main axis is horizontal for row direction and vertical for column direction.

It accepts six values:

  • flex-start - aligns the items to the start of the container.
  • flex-end - aligns the items to the end of the container.
  • center - aligns the items to the center of the container.
  • space-between - items are evenly distributed in the axis. first item is on the start, last item on the end.
  • space-around - items are evenly distributed in the axis with equal space around them.
  • space-evenly - items are distributed so that the spacing between any two items (and the space to the edges) is equal.

The default value of a flex container is flex-start.

Example,

.container {
  display: flex;
  justify-content: flex-end;
}
challenge icon

Challenge

Easy

Define the alignment along the main axis of the given flexbox to space-between.

You should try all the values!

Try it yourself

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css">
</head>
    <body>
        <div class="container">
            <div>1</div>
            <div>2</div>
            <div>3</div>
        </div>
    </body>
</html>

All lessons in CSS Flexbox - The Complete Course