响应式滚动div高度

use*_*svm 1 html css

我有一个固定的页脚。我有一个相对的标题。在这些容器之间有设置为overflow-y:auto的内容。这意味着滚动条应该仅在该 div 容器中显示。我在这个内容 div 周围有一个容器。该 div 的高度设置为像素,因为使用百分比时,它会自动变为 100% 并且滚动条不可见。在不改变屏幕高度的情况下,它看起来 100% 完美。但是,如果用户要更改屏幕的高度,则用户将无法看到 div 中的所有内容,因为固定页脚现在覆盖了该内容。当用户缩小时,页脚和 div 之间有一个空白。我希望这样当用户缩小时没有空白区域,并且当用户更改屏幕高度时,用户可以查看所有内容。

超文本标记语言

<div class="top-container">
 </div>
<div class="container">
<ul>
<li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
</ul>
</div>
<footer>

</footer>
Run Code Online (Sandbox Code Playgroud)

CSS

.top-container {
position: relative;
z-index: 6;
background: #fff;
padding: 40px 40px 0;
bottom: 0; 
width: 100%
}
.container {
padding: 10px 0;
margin: 0 .6%;
}
ul {
padding-top: 2px;
height: 437px;
overflow-y: auto;
overflox-x: hidden;
}
footer{
 background: #fff;
padding: 20px 50px;
overflow: hidden;
position: fixed;
z-index: 5;
left: 0;
bottom: 0;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)

JSFIddle这个 JSfiddle 没有准确地显示我的问题。滚动条应该只显示在内容中,而不是标题中。现在就是这样。

谢谢

Sya*_*lai 5

.top-container {
  position: relative;
  z-index: 6;
  background: #fff;
  padding: 40px 40px 0;
  bottom: 0; 
  width: 100%;
  max-height: 60px;
  background: green;
}
.container {
  padding: 10px 0;
  margin: 0 .6%;
  overflow-y: scroll;
  height: calc(100vh - 100px);
  background: blue;
}
ul {
  padding-top: 2px;
  height: 437px;
  overflow-y: auto;
  overflox-x: hidden;
}
footer{
  background: #fff;
  padding: 20px 50px;
  overflow: hidden;
  position: fixed;
  z-index: 5;
  left: 0;
  bottom: 0;
  width: 100%;
}
body{
  max-height: 90vh;
  }
footer{
  background: red;
  max-height: 40px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="top-container">

</div>
<div class="container">
  <ul>
    <li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li>
  </ul>
</div>
<footer>

</footer>
Run Code Online (Sandbox Code Playgroud)

这是更新后的jsFiddle