css - 两个具有 flex shrink 和 flex-basis 值的 div 的高度究竟是如何计算的?
问题描述
我有如下的html和css。
.container {
height: 200px;
background-color: grey;
display: flex;
flex-direction: column;
}
.top {
flex: 0 0 10%;
background-color: red;
}
.middle {
flex: 0 2 20%;
background-color: cyan;
}
.bottom {
flex: 0 1 80%;
background-color: orange;
}
<div class="container">
<div class="top">top</div>
<div class="middle">middle</div>
<div class="bottom">bottom</div>
</div>
容器 div 的高度为 200 像素。top div 的 flex-grow 和 flex-shrink 值为 0, flex-basis 值为 20%。所以顶部 div 的高度是 20px (200 * 0.10)。直到这里一切正常。浏览器究竟如何计算具有 flex-shrink 和 flex-basis 值的中间和底部 div 的计算高度?(剩余的 180px 如何在这两个 div 之间划分。)
解决方案
推荐阅读
- javascript - 如果再次调用该函数,如何停止执行该函数的第一次调用?
- javascript - Google 登录 API 不对称 - 泄露用户帐户
- c# - C# WPF - MainFormPaint 生成的图像在预先创建的 PictureBox 图像上分层
- reactjs - React Native TextInput 值不断刷新
- blogger - 如何在首页随机显示博主帖子?
- asp.net-core-2.0 - 将 .Net Core API 导入和部署到 Azure API 管理
- python - Python将对象添加到for循环迭代中的每个项目
- amazon-web-services - 从代码管道调用第三方 API 的最佳方式
- docker - 为什么 kuberntes 中的 docker 容器每隔几分钟退出并重新启动
- r - 酒吧和餐饮店的边界,ggplot