I have a flexbox row container with an icon of unspecified width as the left flex-item and a multi-line block of text as the second flex item.
The thing is, I want this text to be in the exact center of the flexbox container, and at the moment it is pushed to the left by the first flex item.
One way to center it is to pad the right-hand side of the text box to the same width as the icon, e.g. using margin-right.
Or perhaps I could set an :after
element on the text to add another flex box to the right? What's the best way to do this?
E.g.
<div style="display: flex; width: 10em; align-items: center; border:1px solid blue; text-align:center">
<a style="flex: none; width:auto">→</a>
<a style="flex:1; /* margin-right: how do I make this the same width as the → box above*/">here <br> is a load of text.<br>I want it to be centered in the div,<br>not shifted to the right</a>
</div>