Assume that i have the code below
So basically i have a design to show the 'vs prev period' with a percentage, and they has to be in same line, so i use display: flex
in this case
The problem is we want that the gap between two child to always be 2px when rendering. However, when the content of left child or content of right child is too long, making the left child content wrap to second line (which is what we want). However, when this happens, the gap between 2 children is no longer 2px, because there is a white spaces in left child.
I add a screenshot here, you can see there is space which is indicated with blue box, making the total gap between 2 children no longer 2px.
So the question is when this happens, is there anyway to remove this bluebox spaces, so that it can force the gap to always be 2px.
What we want in design:
Thanks
p/s: using word-break:break-all
to the left child is not a good UX solution, we still want break by word, but somehow remove the whitespaces
.parent{
display:flex;
max-width: 200px;
gap: 2px;
margin-bottom: 20px;
}
.text{
background: yellow
}
.number {
background: lightblue;
}
<div class='parent'>
<div class='text child'>vs prev period</div>
<div class='number child'>1.23%</div>
</div>
<div class='parent'>
<div class='text child'>vs prev period vs prev vs prev</div>
<div class='number child'>1.23%</div>
</div>
<div class='parent'>
<div class='text child'>vs prev period</div>
<div class='number child'>3,221,189,823.23%</div>
</div>