I have three divs inside a flex container. They are intended to exist in two rows:
- First row:
- one with fixed width
- other should stretch on remaining width
- Second row:
- one item
But div 1 stretches to 100% width (and pushes div 2 to the next line);
*{
box-sizing: border-box;
}
.parent{
display: flex;
flex-flow: row wrap;
}
.parent > div{
flex: 2 1 auto;
border: 1px solid gray;
text-align: center;
}
.parent > div.child1{
background: lightblue;
}
.parent > div.child2{
flex: 0 1 200px;
background: lightgreen;
}
.parent > div.child3{
flex-basis: 100%;
background: lightcoral;
}
.parent > div.child1-1{
background: lightblue;
flex-basis: 80%;
max-width: 80%;
}
.parent > div.child2-1{
flex: 0 1 20%;
background: lightgreen;
}
<div class="parent">
<div class="child1">first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first </div>
<div class="child2">second</div>
<div class="child3">third</div>
</div>
<br><br><br>
<div class="parent">
<div class="child1-1">Should be like this, but with fixed width. <br>first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first </div>
<div class="child2-1">second</div>
<div class="child3">third</div>
</div>
Here is an example: codepen.io