css - 带有页眉和页脚的 100% Css 布局

标签 css layout height

我正在尝试创建一个布局,其中包含页眉和页脚(两者都有固定的高度)以及它们之间的内容 div,用于填充剩余空间。在 content-div 中,我希望 div 的高度基于百分比值(以 content-div 的 heihgt 作为父级)。我不知道该怎么做?

这是我正在努力完成的一个例子。 layout example

最佳答案

[ See it in action ]

  #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; 
  }

关于css - 带有页眉和页脚的 100% Css 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3186123/

相关文章:

html - 无法在流体 Div 中将流体图像居中

html - CSS布局问题

jquery - 如果 JQuery Mobile 内容溢出,如何通过滚动保持面板高度固定

javascript - 在预订小部件上向 "Check In Date"添加 2 天

html - html 菜单项中的左对齐和右对齐文本

html - 如何垂直对齐段落中的文本?

android - 如何显示大于手机屏幕尺寸的图像?

html - iPhone 5主屏-web应用适配高度

html - 当我将图像添加到容器中时,我无法使其响应

javascript - 包含大量图片的网页 : slow scrolling?