【发布时间】:2014-12-31 01:11:25
【问题描述】:
我正在尝试在包装 div 中堆叠 2 个 div。我需要一个设置高度的 div 来保持在包装 div 的 bottom 上,并且我需要 top div 来滚动。我无法将它们分开,因为我希望包装器随着顶部 div 中的内容一起增长,直到它对于屏幕来说太大,然后开始滚动而不隐藏底部 div。
这是example。
我几乎可以弄清楚这一点,但是 bottom div 与 content div 中的最后一点信息重叠。有没有办法改变 top div 的高度,以便为 bottom div 留出空间,无论它的高度如何?
HTML
<div class="wrapper">
<div class="top">
<div class="content">
// Dynamically added information that
// grows the height of div.content
</div>
</div>
<div class="bottom">
// Input box or static button panel
</div>
</div>
SCSS
.wrapper {
max-height: 100vh;
position: relative;
overflow: hidden;
.top {
max-height: inherit;
overflow: hidden;
.content {
max-height: inherit;
overflow-y: scroll;
}
}
.bottom {
position: absolute;
bottom: 0;
}
}
【问题讨论】:
标签: css scroll height overflow