I want to have a flex-box with a maximum width that wraps beyond that width, but that also fits the maximum size of any given "row" within the flexbox.
The problem I am facing now is that any element that stretches beyond the maximum width and then wraps causes the flexbox to still take up that maximum width.
Here is a link to a codepen demonstrating the issue:
https://codepen.io/heroes-coding/pen/rNaGYmo
And here is the top container's html / css:
body {
background: black;
}
.holder {
width: 650px;
background: gray;
margin-top: 50px;
}
.flexbox {
display: flex;
background: blue;
max-width: 500px;
width: fit-content;
flex-wrap: wrap;
}
.item {
width: 100px;
height: 50px;
background: red;
border-bottom: 1px dotted white;
border-top: 1px dotted white;
border-right: 1px dotted white;
}
.item.wide {
width: 200px;
}
<div class="holder">
<div class="flexbox">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</div>
I'd like to have the flexbox still wrap at 500px but shrink to fit the content after the wrapping occurs.