
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. You cannot display flex items inline otherwise you don't actually have a flex layout. In particular, the flex items themselves always behave like block-level boxes (although they do have some properties of inline-blocks). 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. 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.


That is the only difference between display: inline-flex and display: flex. It makes the flex container display inline. Display: inline-flex does not make flex items display inline. When an element has intrinsic dimensions, we can use 0 for top and bottom, then apply margin: auto. Absolute positioning and margin: autoĪn element with no intrinsic size can be centered by simply using equal values from the top and bottom. Side Note: Unless explicitly stated, each strategy highlighted below will work with inline elements as well, which makes sense given that we’ll be directly transforming their position or display properties. Align on the grid container or the grid item.


Facundo Corradini Follow Frontend developer, CSS specialist, best cebador de mates ever.
