2015-08-03 100 views
1

我想创建页脚被固定在页面的底部,它会显示只有当我向下滚动至底部。 我想让它变成这样,因为现在是最重要的。我添加了一个加载页面,页面上可以看到页脚。页脚始终固定在页面引导的底部?

那么,如何让页脚等等泰始终在页面的底部。我接受关于在加载页面打开时如何隐藏它的任何其他建议。

这里是页脚代码:

<nav class="navbar navbar-default navbar-bottom" role="navigation"> 
    <div class="container"> 
    <h1>Hello World</h1> 
    </div> 
</nav> 

提前感谢!

回答

1

HTML

<div id="footer"></div> 

CSS

#footer { 
    position:fixed; 
    background-color:#000; 
    left:0px; 
    bottom:0px; 
    height:100px; 
    width:100%; 
    display:none; 
} 

JS

$(window).scroll(function() { 
    if ($(this).scrollTop() < 100) { 
     $("#footer").hide(); 
    } 
    else { 
     $("#footer").show(); 
    } 
}); 

Demo here

0

请与下面的链接。

Fiddle

.footerfix{height:4rem;} 
footer{ 
    position: absolute; 
    right: 0; 
    bottom: 0; 
    left: 0; 
    padding: 1rem; 
    text-align: center; 
    background-color: #222; 
}