我希望每个单元格都是行的1/3。我尝试用flexbox实现这一点,但与CSS属性“flex:1”的框,就像他们有“宽度:50%”。我怎样才能防止flexboxes行的剩余宽度?
小提琴例如:http://jsfiddle.net/skip405/NfeVh/1073/
HTML:
<div class="container">
<div class="row">
<div class="cell">
</div>
<div class="cell">
</div>
</div>
</div>
的CSS:
.container {
width: 100%;
background-color: gray;
}
.row {
background: #ccc;
display: flex;
flex: 3;
flex-direction: row;
}
.cell {
width: 50px;
height: 50px;
background-color: white;
border:1px solid black;
display: flex;
flex: 1;
}
他们占用了剩余的空间。 如果你添加3个孩子到柔性容器,并给他们所有flex-grow1属性,他们将占用容器的三分之一 –
有没有办法让2个单元格占用2/3的行并离开1/3排空了? –