【发布时间】:2013-04-04 06:50:05
【问题描述】:
我有一个 3 容器结构。 容器 1 的高度为 x...容器 2 填满了窗口的其余部分...容器 3 应该在容器 2 之后启动,但它消失了。
HTML
<header>
</header>
<div id="maincontent">
</div>
<footer>
</footer>
css:
html,body{padding:0; margin:0;}
header{
background-color:red;
height:1.8em;
}
#maincontent{
background-color:black;
position:absolute;
top:1.8em;
bottom:0;
width:100%;
}
footer{
background-color:yellow;
height:50px;
}
如何获取容器 3(容器 2 后面的页脚)。 我知道导致问题的容器 2 的绝对位置,但这是我可以让该容器填满屏幕的唯一方法。
我尝试过使用边距,但无济于事;
更清楚地解释我想要实现的目标:
容器 1 + 容器 2 = 100% 高度。然后滚动查看容器 3。
我可以在 javascript 中实现这一点,但希望它可以在 css 中实现。
【问题讨论】: