html - CSS - 父级的 Flexbox 子级高度(多列)
问题描述
有很多示例解释了如何让 flexbox 子对象的高度达到其父对象的 100%,但是当我添加多个列时,各种策略都不起作用。
下面的代码最终将盒子堆叠在一起,它们应该并排。
https://jsfiddle.net/pqmv4pc4/
#snippet-container {
height: 300px;
width: 200px;
}
#page {
display: flex;
flex-flow: column;
height: 100%;
}
#content {
display: flex;
height: 100%;
background: blue;
width:50%;
}
#content .test {
width: 100%;
height: 100%;
background: yellow;
border: 2px solid red;
}
<div id="snippet-container">
<div id="page">
<div id="content">
<div class="test"></div>
</div>
<div id="content">
<div class="test"></div>
</div>
</div>
</div>
解决方案
#page
应该flex-flow: row;
不是列。
#snippet-container {
height: 300px;
width: 200px;
}
#page {
display: flex;
flex-flow: row;
height: 100%;
}
#content {
display: flex;
height: 100%;
background: blue;
width:50%;
}
#content .test {
width: 100%;
height: 100%;
background: yellow;
border: 2px solid red;
}
<div id="snippet-container">
<div id="page">
<div id="content">
<div class="test"></div>
</div>
<div id="content">
<div class="test"></div>
</div>
</div>
</div>
推荐阅读
- jboss - NoClassDefFoundError:无法链接 org/glassfish/jersey/server/ResourceConfig
- scala - 如何从类名中获取伴随对象?
- python - 在 Python 中使用非 ascii 字符文件名(表情符号)操作文件
- java - 如何在 Apache Beam 中使用 BigQuery IO 写入 BigQuery?
- python - 具有长时间启动和 gunicorn 超时的应用程序
- uml - 分析阶段的序列图和序列图设计阶段的序列图有什么区别?
- apache-spark - Spark 任务是否在计算之前读取了整个 HDFS 块?
- flutter - Flutter:使用“.difference()”函数获取两个格式化时间值的差异
- javascript - 如何在 WordPress 上仅排除空页面在 Google 中的索引
- javascript - 如何挂钩新 String 实例的每次创建?