html - 带页眉和页脚的两列液体布局

标签 html css css-position fluid-layout

我的 HTML 页面有 2 列以及页脚和页眉:

<div id="main">
   <div class="header"> </div>
   <div class="left"> </div>
   <div class="data"> </div>
   <div class="bottom"> </div>
</div>

在我的例子中,我希望左 DIV 具有自动宽度,而数据 DIV 具有 100% 宽度。就像这张图片: enter image description here 如何在 IE 6 支持下使用 CSS?谢谢!

最佳答案

Demo

html

<div class="header">
    header content
</div>

<div class="content">
    <div class="left">left</div>
    <div class="right">right</div>
</div>

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

CSS

body, html{
    padding:0;
    margin:0;
    position:relative;
    height:100%
}
.header, .footer{
    width:100%;
    background:#ccc;
    padding:10px;
    box-sizing:border-box;
}
.content{
    background:#eee;
    width:100%;
    padding:10px;
    height:100%;
    box-sizing:border-box;
    padding:10px;
}
.left{
    width:50%;
    float:left;
    background:#bbb;
    height:100%;
}
.right{
    width:50%;
    float:right;
    background:#aaa;
    height:100%;
}

根据需要 DEMO

CSS

保持一切与上面相同,只是更改下面的 css

.content{
    background:#eee;
    width:100%;
    padding:10px;
    height:100%;
    box-sizing:border-box;
    padding:10px;
    display:table
}
.left{
    width:auto;
    background:#bbb;
    height:100%;
    display:table-cell
}
.right{
    background:#aaa;
    height:100%;
    display:table-cell;
    width:100%
}

关于html - 带页眉和页脚的两列液体布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27920244/

相关文章:

html - float 与绝对和相对 div 定位有何关系?

JavaScript 函数在鼠标悬停时不起作用

javascript - 输入在空输入上返回 true

html - 与图像一起调整 hover_mask 的大小

jquery - 如何防止在图像 slider 上加载背景图像

jquery - HTML/CSS - 阴影图像调整大小

html - 放置一个左边有绝对空间,顶部有 float 特性的方 block

css - 固定位置但相对于容器

javascript - 隐藏页脚 javascript 中的固定元素

javascript - 使用 javascript 更改 <audio> src