【问题标题】:Bootstrap footer on bottom of the page [closed]页面底部的引导页脚[关闭]
【发布时间】:2014-09-08 04:19:18
【问题描述】:

我试图让我的网站的页脚始终保持在底部。以及我希望内容区域至少具有视口的高度。意思是在视口中,您应该在 op 上看到 header。中间的content 部分和底部的footer。如果文章的长度超出视口的大小,则页脚应该向下,内容部分应该更长。

这是我的代码http://bit.ly/1Bl3Jd5

非常感谢。

【问题讨论】:

标签: html css twitter-bootstrap


【解决方案1】:

您需要用另一个容器包装.container.footer 并应用样式:

#fullheight {
    position: absolute;
    display: table;
    height: 100%;
    width: 100%;
    z-index: 2;
    overflow: hidden;
    top: 0;
    left: 0;
    padding-bottom: 146px;
}

对于需要添加的页脚:

position: absolute;
bottom: 0;

http://jsfiddle.net/vmjc1w2q/

降低预览高度以查看效果。

编辑

如果你想要其他行为试试这个:

footer {
    width:100%;
    height:143px;
    position:fixed;
    bottom:0;
    left:0;
}

【讨论】:

    【解决方案2】:

    要强制页脚始终可见,请将其位置设置为绝对。

    CSS:

    #footer {
        width:100%;
        height:143px;
        position:absolute;
        bottom:0;
        left:0;
    }
    

    编辑:现在我得到了你想要的。 http://www.cssstickyfooter.com/ 展示了如何归档行为:

    CSS:

    html, body { height:100%; }
    
    #main { padding-bottom: 143px; }
    
    #wrapper {
        position: relative;
        min-height:100%;
    }
    
    #footer {
        width:100%;
        height:143px;
        position:absolute;
        bottom:0;
        left:0;
    }
    

    【讨论】:

    • 它不适用于所有页面。以这个页面为例:bit.ly/ZdNOQi 内容在页脚后面流动并在其下方继续。
    • 知道了,我编辑了帖子。
    • 这也是Bootstrap应该做的方式吗?
    猜你喜欢
    • 2017-04-12
    • 1970-01-01
    • 2013-01-24
    • 2015-06-26
    • 2021-01-19
    • 2015-07-23
    • 2013-05-17
    • 2017-12-05
    • 2013-01-04
    相关资源
    最近更新 更多