带页眉和页脚的100%Css布局

Sna*_*ail 7 css height layout

我正在尝试创建一个带有页眉和页脚的布局(两者都有固定的高度)和一个填充剩余空间的内容div.在content-div中,我希望div具有基于百分比值的高度(以content-div的heihgt为父级).我无法弄明白该怎么做?

这是我想要完成的一个例子. 布局示例http://img22.imageshack.us/img22/45/layoutbz.png

gbl*_*zex 5

[ 看到它在行动 ]

  #header { 
    position:absolute; 
    height: 50px; 
    left:0; 
    top:0; 
    width:100%; 
    background:green;
  }

  #footer { 
    position:absolute; 
    height: 50px; 
    left:0; 
    bottom:0; 
    width:100%;
    background:green;
  }

  #content { 
    position: absolute; 
    top:50px; 
    bottom:50px; 
    left:0;
    width:100%;
    background:#eee; 
  }

  #box1 { 
    height:50%; 
    width:30%; 
    float:left; 
    background:red; 
  }
Run Code Online (Sandbox Code Playgroud)

  • @aaaidan只需将`overflow` css属性添加到`#content`中.请参阅:http://jsbin.com/erawu3/63 (2认同)