I'm trying to overlay a div with some text over another div with two images that I want left and right aligned. I've used flexboxes in the past, so I was confused why this wasn't working, but noticed once I removed position:absolute
from the styles that the two images acted as I intended (with the side effect of no longer overlaying the two divs on each other). It works as desired if I set the width in pixels, but because I'm designing across screen sizes I want to avoid doing that if possible.
I saw this question that says position:absolute
shouldn't conflict with flex boxes so I'm not sure why I'm running into this issue.
Here is a codepen, as you can see, when you remove the absolute positioning, the cat image moves to the far right, but when it is in place, the cat is immediately adjacent to the dog.
<div style="display:flex;justify-content:space-between;position:absolute;z-index: -1;">
<div>FOO</div>
<div>BAR</div>
</div>
<div>
SOME TEXT
</div>