CSS Flexbox: justify-content

The justify-content property controls how items are positioned along the main axis  (horizontally – if flex-direction property is set on row). This property is applied to the flex-items after margins and flex-grow values are calculated.

Syntax

justify-content: flex-start;
justify-content: flex-end;
justify-content: center;
justify-content: space-between;
justify-content: space-around;
justify-content: safe center;
justify-content: unsafe center;

margin: auto

However, if any flex-item has an auto margin on the main axis the justify-content property will have no effect on that item’s position.

See the Pen CSS Flexbox justify-content, margin: auto by majadc (@majadc) on CodePen.

flex-start (default)

1
2
3
4
1
2
3
4
5
6
7
8
9
10
11
12
13
14

flex-end

1
2
3
4
1
2
3
4
5
6
7
8
9
10
11
12
13
14

center

1
2
3
4
1
2
3
4
5
6
7
8
9
10
11
12
13
14

space-between

1
2
3
4

space-around

1
2
3
4

space-evenly

1
2
3
4

safe – supported by Firefox

justify-content: safe center;
1
2
3
4
5
6
7
8
9
10
11
12
13
14

unsafe – supported by Firefox

justify-content: unsafe center;
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Related

Resources

Posted in CSS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.