設定了 Flexbox 的排序方向後 (Flexbox 基本概念 01),接著最常設定的便是當中物件的對齊方式,如置中、置右等等。
為 Flexbox 設定物件對齊的方法為 justify-content,要注意對齊方式是跟據排序方向 flex-direction 來考慮,例如置中的對齊方式,在橫向水平排序下便會成為水平置中,在縱向垂直排序下便變成為垂直置中。
看看以下例子:

<div class="container">
<div class="item">item 1</div>
<div class="item">item 2</div>
<div class="item">item 3</div>
</div>
.container {
display:flex;
flex-direction: row;
justify-content: center;
height:250px;
background-color:cornflowerblue;
padding:10px;
}
flex-direction: row 及 justify-content: center 兩個設定便會使 item 在 container 中水平置中。
若將排序方向更改為縱向垂直 flex-direction: column,就會變成 item 在 container 中垂直置中:

另外,justify-content: flex-start 及 justify-content: flex-end 分別為開始對齊(默認)及末端對齊。
其餘幾樣較特別的對齊方式有 space-around、space-between 和 space-evenly,效果分別如下(* 以下例子均為 flex-direction: row 情況下):
justify-content: space-around 每個 item 左右兩邊都有相同的間距(item 之間的間距會是首尾間距的兩倍)

justify-content: space-between 每個 item 之間有相同的間距,首尾沒有空位

justify-content: space-evently 首尾及每個 item 之間也有相同的間距
