Desired Outcome:
I have three elements within a container styled with display: flex
. My goal is to align the left item to the left, the right item to the right, and have the middle item centered.
space-between
does not achieve this look due to the varying widths of the elements. Even with differing widths, I want the center element to remain centered.
To resolve this, one could use a wrapper with flex: 1
on the wrappers for each element. However, in my specific case, I am unable to utilize wrappers.
.parentContainer {
display: flex;
justify-content: center;
align-items: center;
}
.parentContainer > *{
background: red;
text-align: center;
}
<div class="parentContainer">
<div class="left">small</div>
<div class="middle">medium element here</div>
<div class="right">longer element is here too</div>
</div>