CSS粘贴页脚的问题 [英] Problems with CSS sticky footer

查看:121
本文介绍了CSS粘贴页脚的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现一个CSS粘性页脚。

I am trying to implement a CSS sticky footer.

问题是有一个内容DIV扩展超出其容器,导致不希望的滚动条,

The issue is there is a content DIV that is extending beyond its container causing scroll bars that are not desirable and the background-image hung off the page div does not extend the full height of the document.

这是我的HTML:

    <div id="page">
          <div id="header">
            <dl>
                <dt>Header links -</dt>
                <dd><a href="#">link 1</a></dd>
                <dd><a href="#">link 2</a></dd>
                <dd><a href="#">link 3</a></dd>
            </dl>
          </div>
        <div id="content">
            <p><a id="modal" href="popup.html" target="_blank">link to popup</a></p>
        </div>      
        <div id="footer">
            <dl>
                <dt>Footer links -</dt>
                <dd><a href="#">link 1</a></dd>
                <dd><a href="#">link 2</a></dd>
                <dd><a href="#">link 3</a></dd>
            </dl>
        </div>
    </div>

这里是CSS:

/*--------------------------------------------------------------- global */

html, 
body {
    color:#969696;
    font-size:100%;
    height:100%;
}

body {
    font:normal 200 70% Arial, Helvetica, Verdana, sans-serif;  
}

a, 
a:link, 
a:visited, 
a:hover, 
a:active {
    border-bottom:1px dashed #ff8400;
    color:#ff8400;
    text-decoration:none;}

a:hover {
    border-bottom-style:solid;}

/*--------------------------------------------------------------- layout */

#page {
    background:url("../images/bgMain.jpg") repeat-y center top;     
    height:100%;
    margin:0 auto;
    position:relative;
    width:1024px;
}

dl, 
dt, 
dd {
    float:left;
} 


dd {
    margin:0 .2em 0;
}

dd:after {
    color:#969696;
    content:"|";
    padding:0 0 0 .3em;
}

dd:last-child:after {
    content:"";
}

/*----------------- header */

#header {
    margin:0 auto;
    width:726px;
}

#header dl {
    float:right;
    line-height:60px;
}

/*----------------- content body */

#content {
    background:#fff;
    border-top-left-radius:5px;
    border-top-right-radius:5px;
        -moz-border-radius-topleft:5px;
        -moz-border-radius-topright:5px;
        -webkit-border-top-left-radius:5px;
        -webkit-border-top-right-radius:5px;
    box-shadow:0 0 12px 0 rgba(0, 0, 0, .1);    
        -moz-box-shadow:0 0 12px 0 rgba(0, 0, 0, .1);
        -webkit-box-shadow:0 0 12px 0 rgba(0, 0, 0, .1);
    clear:both;
    height:100%;
    margin:0 auto;  
    min-height:100%;
    padding:16px 13px 22px;
    position:relative;
    width:700px;
}

/*----------------- footer */

#footer {
    clear:both;
    margin:-22px auto;
    position:relative;
    width:726px;
}

#footer dl {
    display:inline; 
    margin:0 0 0 13px;
}

#footer a, 
#footer a:link, 
#footer a:visited, 
#footer a:hover, 
#footer a:active {
    border-bottom-color:#969696;
    color:#969696;
}


推荐答案

http://css-tricks.com/\">CSS Tricks 网站在其 Snippets 区域粘性页脚的代码段

The fantastic CSS Tricks website has, in their Snippets area a snippet for a Sticky Footer


http://css-tricks.com/snippets/css/sticky-footer/

或使用jQuery


http://css-tricks.com/snippets/jquery/jquery-sticky-footer/

最新连结与演示

这篇关于CSS粘贴页脚的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆