固定位置容器内的可滚动内容

dcl*_*son 5 css css-position scrollable responsive-design

我有一个 Bootstrap 构建的网站,其中包含一个覆盖页脚,单击页脚菜单即可打开该页脚。

页脚内部是一个可滚动的内容区域,当在可滚动 div 上设置固定高度时,该区域可以正常工作。由于网站是响应式的,我需要这个可滚动区域的百分比高度似乎延伸到可见窗口之外。

一个例子在这里: http: //jsfiddle.net/JUESu/5/

#footer-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: black;
    opacity: 1;
    display: block;
    color: #7f7f7f;
    height:85%;
}

.scrollable {
    overflow-y: scroll;
    height: 50%; /* Doesnt Work */
    /*height: 300px; /* Works */
    width: 95%;
    background: red;
}
Run Code Online (Sandbox Code Playgroud)

如何在固定位置容器内放置可滚动的 div?

小智 4

给出最大高度应该可以解决这个问题

.scrollable {
    overflow-y: scroll;
    max-height:300px;
    height: 50%;
  
    width: 95%;
    background: red;
}
Run Code Online (Sandbox Code Playgroud)

这是小提琴 http://jsfiddle.net/JUESu/10/