有什么方法可以让红色区域填充可视区域的其余部分,但不像现在那样延伸到页脚中?我还需要 infoContent 部分是可滚动的。标题部分的高度是可变的。
我发现了一堆几年前的答案,说要使用 JavaScript,但是有没有可以在现代浏览器中使用的技术来避免这种情况?
HTML:
<div id="page">
<aside id="infoBar">
<header>Variable Sized Header</header>
<div id="infoContent">
<div>First Content Item</div>
<div>Second Content Item</div>
<div>Third Content Item</div>
</div>
</aside>
<footer id="footer">Footer</footer>
</div>
CSS:
#footer { position:fixed; bottom: 0; height: 50px; background-color: rgba(0, 0, 255, 0.5); width: 100%;}
#infoBar { position: fixed; right:0; top: 0; bottom: 50px; padding: 5px; border: 1px solid black; width: 200px; }
#infoBar > header { height: 50px; }
#infoContent { height: 100%; background-color: red; overflow-y: auto; }
#infoContent > div { margin: 5px; height: 50px; background-color: yellow; }
这是一个可以玩的小提琴:http: //jsfiddle.net/gWmtD/