In order to achieve my desired effect, I have red elements that must be displayed as flex and cannot be changed. I want to place text above the middle of these red elements.
The expected result is shown in this image: https://i.sstatic.net/w3cQS.png
Currently, when I try to use a separate div with display:flex to add legends above the elements, the legends are not centered between the elements as intended. The current result can be seen here: https://i.sstatic.net/8ANlV.png
.legendContainer,
.elementsContainer {
display: flex;
}
.legendElement,
.element {
flex: 1;
height: 20px;
}
.element {
margin-left: 1px;
margin-right: 1px;
background: red;
}
<div class="legendContainer">
<div class="legendElement"></div>
<div>..oddXXbboo..</div>
<div class="legendElement"></div>
<div>..oddXXbboo..</div>
<div class="legendElement"></div>
<div>..oddXXbboo..</div>
<div class="legendElement"></div>
<div>..oddXXbboo..</div>
<div class="legendElement"></div>
</div>
<div class="elementsContainer">
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
</div>
What changes should I make to achieve the desired outcome?