我正在使用bootstrap的navbar -fixed bottom在底部添加一个粘性的导航栏。这很好用。我遇到的问题是,当我使用Backbone.Marionette动态添加内容时,导航栏不再停留在底部-相反,它只是停留在相同的位置,隐藏一些内容,最终当我添加更多内容时,内容就会移到导航栏的下方。
有没有一种方法可以强迫导航栏停留在底部,不管添加了多少内容?
发布于 2014-08-06 04:22:49
这是一个没有Bootstrap的老把戏。假设你知道导航栏的高度。你可以试试这个:http://jsfiddle.net/e85xw/
.navbar{
height: 2em;
width: 100%;
background: blue;
color: white;
position: fixed;
top: 100%;
margin-top: -2em;
}如果您不知道导航栏的高度,可以使用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>发布于 2014-08-06 04:41:46
或者干脆..。
.navbar{
position: fixed;
bottom: 0;
left: 0;
right: 0;
/* the rest of the styling */
}我发现它更整洁、更容易。不管你的导航栏有多高。你可以添加高度和颜色以及任何你想要的样式。
https://stackoverflow.com/questions/25147437
复制相似问题