【发布时间】:2015-01-31 13:55:25
【问题描述】:
我的笔:http://codepen.io/anon/pen/QwMRNL
如何让这 3 个 div 共享相同的行高并始终占据屏幕的整个高度?
即使只有 3 或 2 或 1 个项目。它们必须始终共享大小。
- 3 items means each item gets 33% height
- 2 items means each item gets 50% height
- 1 item means each item gets 100% height
<div id="flex">
<div>Temperature</div>
<div>Freeze</div>
<div>Consumption</div>
</div>
#flex {
display: flex;
max-height: 100%;
align-content: center;
flex-direction: column;
}
body {
margin:0;
padding:0;
}
#flex > div:nth-child(1){
background:blue;
}
#flex > div:nth-child(2){
background:red;
}
#flex > div:nth-child(3){
background:yellow;
}
更新:
请不要改变高度:100% 在 body,html 标签中!
【问题讨论】: