0

我尝试了很多方法,经过三天的搜索和工作都没有成功。

html:

<div id="wrapper">
            <div id="header"></div>
            <div id="container">
                <div id="containertable">
                    <div id="leftbar"></div>
                    <div id="contents"></div>
                    <div id="rightbar"></div>
                </div>
            </div>
            <div id="footer"></div>
         </div>

CSS:

<style>
html{
   overflow-y: scroll;
}
html,
body {
   margin:0 auto;
   padding:0;
   height:100%;
   width: 1024px;
}
#wrapper {
   min-height:100%;
   position:relative;
   background: blueviolet;
}
#header {
   background:#ff0;
   width: 1024px;
   height: 70px;
}
#container {
   padding-bottom:60px;   /* Height of the footer */
   display: table;
}
#containertable{
    width: 1024px;
    display: table-row;
}
#leftbar, #rightbar{
    width: 170px;
    height: 100px;
    display: table-cell;
    background: brown;
}
#contents{
    width: 684px;
    height: 200px;
    display: table-cell;
    background: burlywood;
}
#footer {
   width: 1024px;
   position:absolute;
   bottom:0;
   width:100%;
   height:60px;   /* Height of the footer */
   background:#6cf;
}

使用上面的代码和其他版本,我能够得到第一种和第二种情况,但我无法使列保持 100% 高度和相等并将页脚推到页面底部。

在下图中,我正在寻找所有情况下的第三种情况。

将页脚 div 推到页面底部的三种不同情况

4

1 回答 1

0

Martin Turjak 给出了下面的解决方案,这对我来说非常有用。

提琴手

 http://jsfiddle.net/yellowandred/LznnG/5/

HTML:

<div class="wrapper">
    <div class="column1"><a href="#">Test</a></div>
    <div class="column2">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
    <div class="spacer"></div>
    <div class="footer">Footer</div>
</div>

CSS:

html, body {
    width:100%;
    height:100%;
    margin:0;
    padding:0;
    text-align:center;
}
.wrapper {
    position:relative;
    min-height:100%;
    width:80%;
    margin:0 auto;
    font-size:0px;
}
.wrapper div {
    font-size:16px;
}
.column1, .column2 {
    float:left;
    margin-bottom:30px;
    height:100%;
    bottom:0;
}
.column1::before, .column2::before {
    position:absolute;
    content:'';
    top:0;
    bottom:0;
    background:pink;
    right:0;
    z-index:-1;
}
.column1::before {
    background:green;
    left:0;
}
.column2::before {
    background:blue;
    left:30%;
}
.column1 {
    width:30%;
}
.column2 {
    width:70%;
}
.spacer {
    position:relative;
    clear:both;
}
.footer {
    position:absolute;
    height:30px;
    bottom:0;
    width:100%;
    background:orange;
}
于 2013-10-08T05:46:41.020 回答