I want to center one div horizontally while keeping another one in the left, as shown in the image below:
I managed to obtain the desired layout, shown above, by mixing a flexbox approach (to center the B div) while also using position: absolute; left: 20px
on div A (and setting the parent container to position: relative
), but I don't like using position: absolute
, feels like ancient styling.
How to do this with pure flexbox, without position
tricks?
Note that the sizes of the inner divs (A) and (B) are not known a priori and ideally the width of the divs should fit to content (as shown above).