html - 第二列填充剩余屏幕高度不起作用
问题描述
我有一个固定高度的导航栏,在一个高度固定的control
div 下方,在它下方我有另一个 div calendar
。日历是可滚动的。我希望日历高度具有下方control
和屏幕底部的剩余屏幕高度。这样窗口是不可滚动的,只有日历是可滚动的。但是设置height: 100%
不起作用,也不起作用flex: 1
。
这就是我将高度设置calendar
为固定高度时所拥有的,但正如我所解释的,我希望高度是屏幕尺寸的其余部分。
任何想法?
.navbar {
height: 50px;
background-color: indianred;
}
.window {
display: flex;
flex-direction: column;
flex: 1;
}
.control {
height: 100px;
background: khaki;
}
.calendar {
height: 200px;
width: 100%;
bottom: 0;
left: 0;
}
.wrapper {
position: relative;
background-color: lightgray;
width: 100%;
height: 100%;
overflow: scroll;
}
.main {
width: 1500px;
height: 1500px;
background-color: rosybrown;
display: flex;
flex-direction: column;
}
<nav class="navbar"></nav>
<div class="window">
<div class="control">
</div>
<div class="calendar">
<div class="wrapper">
<div class="main">
</div>
</div>
</div>
</div>
解决方案
在下面运行此代码:我height: calc()
对导航和控件使用了屏幕全高减去 150 像素的方法。
.navbar {
height: 50px;
background-color: indianred;
}
.window {
display: flex;
flex-direction: column;
flex: 1;
}
.control {
height: 100px;
background: khaki;
}
.calendar {
height: calc(100vh - 150px);
width: 100%;
bottom: 0;
left: 0;
}
.wrapper {
position: relative;
background-color: lightgray;
width: 100%;
height: 100%;
overflow: scroll;
}
.main {
width: 1500px;
height: 1500px;
background-color: rosybrown;
display: flex;
flex-direction: column;
}
<nav class="navbar"></nav>
<div class="window">
<div class="control">
</div>
<div class="calendar">
<div class="wrapper">
<div class="main">
</div>
</div>
</div>
</div>
推荐阅读
- reactjs - 如何用 redux 实现反应路由器 protectedRoute?
- java - Hibernate 找不到查询参数,即使它在那里
- javascript - crossfilter.js - 根据单独的维度从组中排除事实
- python - 我可以通过 Python 和 Open3D 从 .obj 文件中选择多个随机点吗
- python - 如何修复此 SQL 语法错误 1064,它说要查看 MySQL 服务器版本以使用正确的语法?
- html - 如何修复底部在垂直滚动时始终显示
- python - 当其中包含字符串时,正则表达式匹配整个段落块
- python - 使用请求的 Python 错误 SSL 版本
- java - 如何计算用于在调用堆栈上保存输入以进行递归的空间
- html - 下拉列表显示彼此相邻的列表元素,而不是彼此下方