简体   繁体   English

Bootstrap Navbar固定底部粘性页脚

[英]Bootstrap Navbar-Fixed Bottom Sticky Footer

I'm using bootstrap's navbar-fixed-bottom to have a sticky navbar at the bottom. 我正在使用引导程序的navbar-fixed-bottom在底部具有粘性导航栏。 This works great. 这很好。 The problem I have is when I use Backbone.Marionette to dynamically add content the navbar no longer sticks to the bottom - rather it just stays in the same spot, hiding some content and eventually the content just goes below it as I add more. 我遇到的问题是,当我使用Backbone.Marionette动态添加内容时,导航栏不再停留在底部-而是停留在同一位置,隐藏了一些内容,最终随着我添加更多内容,内容在其下方。

Is there a way to force the navbar to stay stuck to the bottom regardless of how much content is added? 有没有一种方法可以使导航栏始终停留在底部,而不管添加了多少内容?

Or simply... 或者只是...

.navbar{

  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;

  /* the rest of the styling */

}

A lot neater and easier I find. 我发现它更加整洁和容易。 And doesn't matter how tall your navbar is. 导航栏有多高也没关系。 You can add heights and colours and whatever styling you want after it. 您可以添加高度和颜色,以及之后想要的任何样式。

This is an old trick without Bootstrap. 这是没有Bootstrap的古老技巧。 Supposed you know the height of the navbar. 假设您知道导航栏的高度。 You can try this: http://jsfiddle.net/e85xw/ 您可以尝试以下方法: http : //jsfiddle.net/e85xw/

.navbar{
    height: 2em;
    width: 100%;
    background: blue;
    color: white;
    position: fixed;
    top: 100%;
    margin-top: -2em;
}

If you don't know the height of the navbar, you can use JS for a little help http://jsfiddle.net/2T282/ 如果您不知道导航栏的高度,可以使用JS以获得一些帮助http://jsfiddle.net/2T282/

<style>
.navbar{
    height: 2em;//in case this number is dynamic
    width: 100%;
    background: blue;
    color: white;
    position: fixed;
    top: 100%;
}
</style>

<script>
$(document).ready(function(){
    $('.navbar').css('margin-top',$('.navbar').height() * -1);
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM