更新时间:2022-11-02 09:15:40
编辑:请参阅 Michael_B的回答
如果你使用 flex-direction
vertical(使用列
),然后 justify-content:center
然后你可以使用 text-align:center
也水平居中。
If you make the flex-direction
vertical (using column
) then justify-content: center
centers vertically. Then you can just use text-align: center
to center horizontally as well.
li {
display: flex;
justify-content: center;
flex-direction: column;
text-align: center;
}
这里是操作中: http://codepen.io/anon/pen/Fkhgo