跳到主要内容
CNode

inline-flex和flex的区别?

问答
WwangxuedongOvO发布于 9 年前最后回复 9 年前
2115200

如题目? 真心不明白他们有什么不同,百度搜索了很多,仍然没有满意的答案,答案大多就是:inline-flex把容器作为内联块级弹性伸缩盒显示,而flex把容器作为弹性伸缩盒显示,但是他们到底有什么区别啊?求赐教。

查看回复

回复 (2)

W
wwhgtt#29 年前

stack overflow上copy的

W
wwhgtt#19 年前

display: inline-flex does not make flex items display inline. It makes the flex container display inline. That is the only difference between display: inline-flex and display: flex. A similar comparison can be made between display: inline-block and display: block, and pretty much any other display type that has an inline counterpart.

There is absolutely no difference in the effect on flex items; flex layout is identical whether the flex container is block-level or inline-level. In particular, the flex items themselves always behave like block-level boxes (although they do have some properties of inline-blocks). You cannot display flex items inline; otherwise you don't actually have a flex layout. It is not clear what exactly you mean by "vertically align" or why exactly you want to display the contents inline, but I suspect that flexbox is not the right tool for whatever you are trying to accomplish

参与回复

登录后即可参与回复。登录