【发布时间】:2014-05-25 01:24:19
【问题描述】:
我正在尝试将一个 flexbox 嵌套在另一个 flexbox 中。外盒是垂直的:
+------+
| |
+------+
| |
| |
| |
+------+
顶部区域适合内容flex 0 1 auto,下半部分填充剩余空间flex 1 1 auto。
在下半部分,我有另一个水平方向的 flex-box。我希望 2 个内盒在 align-items 的交叉和 flex-end 之间有空格,所以基本上 2 个内盒被固定在左右底角,如下所示:
+------+
| |
+-+ +-|
|L| |R|
+------+
设置这个似乎在 Firefox 中有效,但在 Chrome(Blink) 和 Safari 中我得到了这个:
+------+
| |
| |
| |
+-+--+-|
|L| |R|
+-+ +-+
这是 HTML
<div id="outer">
<div id="top">
top
</div>
<div id="bottom">
<div id="bottomcontents">
<div id="botleft">
bottom left
</div>
<div id="botright">
bottom right
</div>
</div>
</div>
</div>
还有 CSS
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
border: 0px;
}
#outer {
height: 100%;
border: 1px solid red;
display: flex;
display: -webkit-flex;
flex-flow: column;
-webkit-flex-flow: column;
justify-content: center;
align-content: center;
align-items: center;
-webkit-justify-content: center;
-webkit-align-content: center;
-webkit-align-items: center;
min-height: auto;
}
#top {
width: 100%;
flex: 0 1 auto;
-webkit-flex: 0 1 auto;
border: 1px solid blue;
}
#bottom {
width: 100%;
height: 100%;
flex: 1 1 auto;
-webkit-flex: 1 1 auto;
border: 1px solid green;
}
#bottomcontents {
height: 100%;
width: 100%;
border: 1px solid pink;
display: flex;
display: -webkit-flex;
flex-flow: row;
-webkit-flex-flow: row;
justify-content: space-between;
align-content: center;
align-items: flex-end;
-webkit-justify-content: space-between;
-webkit-align-content: center;
-webkit-align-items: flex-end;
min-height: auto;
}
#botleft, #botright {
flex: 0 1 auto;
-webkit-flex: 0 1 auto;
}
#botleft {
border: 1px solid purple;
}
#botright {
border: 1px solid cyan;
}
它在 Firefox 中按预期工作。我做错什么了吗?这是 Chrome 和 Safari 中的错误吗?有解决办法吗?
【问题讨论】: