Normally, an element containing wrapping display:inline-block
elements takes up 100% of the available width, giving you something like this:
-----------------BODY------------------
| |
||-------------CONTAINER-------------||
||-INLINEBLOCK---INLINEBLOCK-- ||
|||____________||____________| ||
||-INLINEBLOCK-- ||
|||____________| ||
||___________________________________||
|_____________________________________|
Say, instead you wanted to shrinkwrap and center the container:
-----------------BODY------------------
| |
| |----------CONTAINER---------| |
| |-INLINEBLOCK---INLINEBLOCK--| |
| ||____________||____________|| |
| |-INLINEBLOCK-- | |
| ||____________| | |
| |____________________________| |
|_____________________________________|
As far as I can tell, this was impossible with traditional CSS and required JavaScript hacks.
Can this problem be solved with flexbox? If so, how?
[Diagrams shamelessly stolen from this question.]