I'm having a problem with flexbox, I'm trying to get my first .cell1
to take on the width of the 3 items inside it so it should be 300px wide so I have set this to flex: 0 0 auto
and I have set .cell2
to flex: 1
so it takes up the remaining space but instead of doing this it seems to overlap .cell1
and I'm not sure why?
How can I get .cell1
to take on the width of the 3 items inside it and .cell2
to take the remaining width?
.wrap {
display:flex;
flex-wrap:wrap;
width: 100%;
}
.cell1{
display:flex;
flex: 0 0 auto;
flex-direction: row;
}
.cell2{
display: flex;
flex: 1;
background: #ff0000;
}
.item1{
flex: 0 0 100px;
background: #ff0000;
}
.item2{
flex: 0 0 100px;
background: #0000ff;
}
.item3{
flex: 0 0 100px;
background: #ff00ff;
}
<div class="wrap">
<div class="cell1">
<div class="item1">
item 1
</div>
<div class="item2">
item 2
</div>
<div class="item3">
item 3
</div>
</div>
<div class="cell2">
cell2
</div>
</div>