2013-08-02 29 views
-3

这是我的代码。 http://jsfiddle.net/LuSBF/2/如何在三个固定容器之间安装动态内容容器

<div class="headmenu"> 
    <div id="logo"></div> 
</div> 
<div class="leftmenu"> 
    left 
</div> 
<div class="rightmenu"> 
    right 
</div> 
<div class="maincontent"> 
    Lorem Ipsum i... 

    <div class="footer"> 
     footer 
</div> 
</div> 

前,左,右是固定的,.maincontent必须适合他们无论窗口的大小。当前.maincontent溢出可用空间并导致水平滚动条。

.headmenu { background: #141414; height: 60px; width: 100%; position: fixed; top: 0; } 
.leftmenu { background: #c11718; height: 100%; width: 100px; position: fixed; margin-top: 60px; top: 0; } 
.rightmenu { background: #141414; height: 100%; width: 200px; position: fixed; margin-top: 60px; right: 0; top: 0; } 
.footer { background: #141414; height: 60px; width: 100%; bottom: 0; } 

#logo { background: url('imgs/logo.jpg'); width: 181px; height: 50px; margin: 5px 0 0 0; } 

.maincontent { width: 79%; border: 1px solid blue; margin: 60px 200px 0 100px; } 

我怎样才能得到.maincontent填写只有标题,右键菜单和左侧菜单中的可用空间?

+1

到底是什么的问题在这里的一个普通例子吗? –

+0

如何让'maincontent'适合'headmenu','leftmenu'和'rightmenu'? – k1tkat

+0

你的问题根本不清楚,你在问什么?为什么你想把主要内容放在其他3个元素中,这是没有意义的。 – dezman

回答

2

更新.maincontent这样:

.maincontent { margin: 60px 200px 0 100px; } 

没有必要指定该块级元素的宽度(因为你希望它填满屏幕减去边距)。没有正确的box-sizing边框会添加滚动条。

您可能还想重置您的CSS;

html, body { margin: 0; padding: 0; } 
+0

哦,就是这样..该死的,谢谢。 :)感谢那些混蛋投票没有任何理由。 – k1tkat