I am trying to achieve the same effect as justify-content and align-items with the value "space-between" on my flex box, but I am facing a challenge because there is no static width/height for the flexbox. Using margins adds space to all sides, whereas I only want space on the sides where flex items meet.
My ultimate goal is to align the very left and very right sides of the flex box's content with the division above it, while still having some space between the items. How can I accomplish this?
Since more flex items will be added/removed dynamically, I need a solution that does not limit support on just the three boxes used in the demonstration below:
div {
text-align: center;
border: 1px solid black;
}
#container {
display: flex;
flex-wrap: wrap;
}
#container div {
flex: 1 1 300px;
margin: 5px;
}
<div>Flex item sides should align with this division's sides</div>
<br>
<div id="container">
<div>Box 1</div>
<div>Box 2</div>
<div>Box 3</div>
</div>