【发布时间】:2015-11-14 11:27:09
【问题描述】:
我想让我的页脚始终显示在页面底部,即使内容没有填满页面,但是当内容填满页面时,我希望它仅在我滚动到页面的最底部时显示. 我正在考虑检查页面是否可以使用 JavaScript 滚动,如果不能,我将添加一个类以固定页脚,否则如果是,则删除该类,但我不知道如何使用 JavaScript 进行检查。 这个想法是,当我无法滚动时,我希望我的页脚固定,而当我可以滚动时,我不希望它固定。我怎样才能做到这一点 ? 我的页脚 HTML 是:
<footer class="smallFooter">
<p> @EDUARDVALENTIN 2015 </p>
<a href="https://www.facebook.com/danadesignsartoria?fref=ufi"><img src="img/fb-logo.png" /></a>
<a href="#"><img src="img/instagram-logo.png" /></a>
<a href="https://www.youtube.com/channel/UCqe4oWvPuSP8kTL70V1P9Gg/feed"><img src="img/yt-logo.png" /></a>
<a href="https://twitter.com/SartoriaAsti"><img src="img/twitter-logo.png" /></a>
</footer>
还有 CSS:
.smallFooter{
bottom:0;
width:100%;
position:fixed;
height:35px;
background-color:#0E0E0E ;
}
.smallFooter p{
position:absolute;
display: inline-block;
box-sizing:border-box;
color:white;
font-size:10px;
float:left;
}
footer img{
width:25x;
height:25px;
display:inline-block;
float:right;
margin-right:3%;
padding-top:8px;
}
【问题讨论】:
-
你可以在身上使用
min-height。 -
添加您的页面 html,包括页眉正文内容和页脚
-
签出this。
标签: jquery html css footer sticky