Bootstrap 3 将页脚刷新到底部.不固定 [英] Bootstrap 3 Flush footer to bottom. not fixed

查看:32
本文介绍了Bootstrap 3 将页脚刷新到底部.不固定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我正在设计的网站使用 Bootstrap 3.

我想要一个像这个示例一样的页脚.示例

请注意,我不希望它 FIXED,所以 bootstrap navbar-fixed-bottom 不能解决我的问题.我只是希望它始终位于内容的底部,并且具有响应性.

非常感谢任何指南.

<小时>

对不起,如果我不清楚.现在发生的情况是当内容正文没有足够的内容时.我的页脚向上移动,然后在底部留下一个空白区域.

这就是我现在的导航栏

<div class="col-sm-4" style="padding: 0 0 0 0px"><p>常见问题</p><p>隐私政策</p>

<div class="col-sm-4"><h5 id='footer-header'>xxxx </h3><p>yyyyyyyyyyyyy</p>

<div class="col-sm-4"><h5 id='footer-header'>xxxxx </h3><p>uuuuuuuuuuuuuuu</p>

</nav>

CSS

.navbar-bottom {最小高度:300px;边距顶部:100px;背景颜色:#28364f;填充顶部:35px;颜色:#FFFFFF;}

解决方案

请看下面的例子.如果页面内容较少,这会将您的页脚定位到底部,如果页面内容较多,则其行为类似于普通页脚.

CSS

* {边距:0;}html,正文{高度:100%;}.包装{最小高度:100%;高度:100%;边距:0 自动 -155px;/* 底部边距是页脚高度的负值 */}.footer, .push {高度:155px;/* .push 必须与 .footer 高度相同 */}

HTML

<p>您的网站内容在这里.</p><div class="push"></div>

<div class="footer"><p>版权 (c) 2008</p>

<小时>

更新:新版本的 Bootstrap 演示了如何在不添加包装器的情况下添加粘性页脚.详情请参阅 Jboy Flaga 的回答.

I am using Bootstrap 3 for a site I am designing.

I want to have a footer like this sample. Sample

Please note that I don't want it FIXED so bootstrap navbar-fixed-bottom does not solve my problem. I just want it to be always at the bottom of the content and also be responsive.

Any guide will be very much appreciated.


EDIT:

Sorry if I wasn't clear. What happens now is that when the content body does not have enough content. My footer moves up and then it leaves an empty space at the bottom.

This is what i have now for my navbar

<nav class="navbar navbar-inverse navbar-bottom" style="padding:0 0 120px 0">
        <div class="container">
            <div class="row">
                <div class="col-sm-4">
                    <h5 id='footer-header'> SITEMAP </h3>
                    <div class="col-sm-4" style="padding: 0 0 0 0px">
                        <p>News</p>
                        <p>contact</p>
                    </div>
                    <div class="col-sm-4" style="padding: 0 0 0 0px">
                        <p>FAQ</p>
                        <p>Privacy Policy</p>
                    </div>
                </div>
                <div class="col-sm-4">
                    <h5 id='footer-header'> xxxx </h3>
                    <p>yyyyyyyyyyyyy</p>
                </div>
                <div class="col-sm-4">
                    <h5 id='footer-header'> xxxxx </h3>
                    <p>uuuuuuuuuuuuuuu</p>
                </div>
            </div>
        </div>
    </nav>

CSS

.navbar-bottom {
min-height: 300px;
margin-top: 100px;
background-color: #28364f;
padding-top: 35px;
color:#FFFFFF;
}

解决方案

See the example below. This will position your Footer to stick to bottom if the page has less content and behave like a normal footer if the page has more content.

CSS

* {
    margin: 0;
}
html, body {
    height: 100%;
}
.wrapper {
    min-height: 100%;
    height: 100%;
    margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
    height: 155px; /* .push must be the same height as .footer */
}

HTML

<div class="wrapper">
  <p>Your website content here.</p>
  <div class="push"></div>
</div>
<div class="footer">
  <p>Copyright (c) 2008</p>
</div>


UPDATE: New version of Bootstrap demonstrates how to add sticky footer without adding a wrapper. Please see Jboy Flaga's Answer for more details.

这篇关于Bootstrap 3 将页脚刷新到底部.不固定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆