css - 如何使 100% 表格高度与最小高度父级一起使用
问题描述
似乎是一个简单的问题,但我无法将内部 div 设置为与最小高度 70vh 设置的父 div 的 100% 高度。我希望里面的表格是 100% 的高度和垂直对齐的内容。如果我将父母身高设置为 70vh,它会起作用,但这不允许更多内容。下面的小提琴:
https://jsfiddle.net/RustyBadRobot/zgesx50L/8/
.hero-row {
position: relative;
z-index: 10;
background: #f8f9fa;
min-height: 70vh;
height: 70vh; /* This makes it work but if content goes over fails to expand */
padding-top: 0;
padding-bottom: 0;
}
.centrize {
position: relative;
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
解决方案
可以通过让元素的子元素继承相同的 来解决这个问题min-height: 70vh
。因此,添加min-height: inherit
到第一个子元素,它应该按预期工作。
.centrize {
position: relative;
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
min-height: inherit;
}
推荐阅读
- mdx - 时间层次结构无法正确解析
- python - 在numpy中逐块重塑?
- c# - 从 CSV 文件中读取所有列
- c# - Hololens 运动识别
- performance-testing - 如何在 Truclient 12.60 中捕获和验证 Web 应用程序页面大小?
- svn - 如何启用 TortoiseSVN 实时状态缓存?
- mongodb - Mongo DB 文档限制
- java - 如果我再移动鼠标,则在鼠标单击停止移动后触发对象移动
- c# - Selenium C#如何检查禁用的元素是否显示
- amazon-web-services - 将文件作为负载传递给 AWS API Gateway