Css 100%高度:在重新调整页面大小时,页脚滚动到内容

时间:2012-06-28 04:19:59

标签: css

我一直在关注从SITE开始使我的网页css 100%高度的教程。我能够实现我想要的,但现在我的页脚出现了问题。每当我调整页面大小时,页脚将略微向上滚动到内容中。有没有办法可以阻止它?这是我的Live EXAMPLE

谢谢

CSS

<style>
html, body {
    margin:0;
    padding:0;
    height:100%; /* needed for container min-height */
    background:#333333;
    font-family: trebuchet, 'trebuchet ms', 'tahoma', sans-serif;
    font-size:small;
    color:#5e5e5e;
    line-height: 130%;
}


/****** COLORBLOCK: this is the orangey-yellow bar behind the wrapper in the background. ******/

#colorblock {
    position: absolute;
    top: 60px;
    left: 0px;
    background: #c69a55;
    z-index: 0;
    height: 65px;
    width: 100%;
    padding: 0px;
    margin: 0px;
}

/**************************************************/



div#container {
    position:relative; /* needed for footer positioning*/
    margin:0 auto; /* center, not in IE5 */
    width:925px;
    background:#f0f0f0;
    height:auto !important; /* real browsers */
    height:100%; /* IE6: treaded as min-height*/
    min-height:100%; /* real browsers */
    border-right: 15px solid #000000;
    border-left: 15px solid #000000;

}

div#contentArea {
    padding:1em 1em 5em; /* bottom padding for footer */

}
    div#contentArea p {
        text-align:justify;
        padding:0 1em;
    }

#content {
    margin-left: 240px;
    margin-right: 0 auto;
    background: #ebebeb;
    padding: 5px;
    width:635px;
    height: 400px;

}

/****** TOP BANNER: This is the banner with Greg's List logo and main navigation. Also includes the styles for the main navigation links. ******/
div#header {
    /*padding:1em;*/
    height: 175px;
    border-top:15px solid #000000;

}
    div#header p {
        margin:0;
    }



/****** LEFT COLUMN: This is the left gray column next to the content. Features the styling for the log-in form and the location links. ******/

#left2 {
    float: left;
    width: 200px;
    background: #dddddd;
    -moz-border-radius: 10px;
    border-radius: 10px;
    margin-right: 15px;
    padding: 5px;
    height: 400px;
}


/****** FOOTER: This is the junk at the bottom of the page. Do NOT remove the clear div; it's what makes it stick to the bottom. ******/


div#footer {
    position:absolute;
    width:100%;
    bottom:0; /* stick to bottom */
    background:#7A7A7A;
    border-bottom:15px solid #000000;
}
    div#footer p {
        padding:1em;
        margin:0;
    }

a.footer {
    color: #c7c7c7;
    font-size: 80%;
    padding-right: 20px;
    letter-spacing: 1px;
}   


p { 
    margin:0 0 1em;
}   

</style>

2 个答案:

答案 0 :(得分:1)

由于您在内容div上设置了明确的高度,您可以执行以下操作:

div#container line 32

上的

padding-bottom:36px;

但是如果您的内容div的高度发生变化,则可能不再考虑该填充。

答案 1 :(得分:1)

margin-bottom:60px;添加到#content css定义。

完整区块:

#content {
    margin-left: 240px;
    margin-right: 0 auto;
    margin-bottom: 60px;
    background: #ebebeb;
    padding: 5px;
    width:635px;
    height: 400px;
}