【发布时间】:2018-08-17 10:35:45
【问题描述】:
我正在尝试使用 bootstrap 4 制作一个粘性页脚。如何确保无论有多少内容始终停留在屏幕底部?我已经查找了关于粘性页脚的其他答案,但无法让它工作,所以我想分享我的代码。我试过从固定的、绝对的和相对的位置改变位置,这些都不起作用。 在另一个项目中,我能够让它与 absolute 一起工作。它与我的 html 和 body 的 css 有关吗?
HTML
<footer class="footer">
<!-- <div class="container-fluid"> -->
<a href="https://www.facebook.com/lucas.stahl.75">
<i class="fa fa-facebook"></i>
</a>
<a href="https://twitter.com/LucasStahl11">
<i class="fa fa-twitter"></i>
</a>
<a href="https://www.linkedin.com/in/lucasstahl">
<i class="fa fa-linkedin"></i>
</a>
<a href="https://lucasstahl.wordpress.com/">
<i class="fa fa-wordpress"></i>
</a>
<p id="copyRight">@Copyright 2018 www.lucasstahl.com</p>
<!-- </div> -->
</footer>
CSS
body,
html {
width: 100%;
height: 100%;
/* min-height: 100%;
position: relative; */
background-position: center;
background-image: url("clark.png");
background-size: cover;
}
.footer {
/* clear: both; */
/* position: absolute; */
background-color: rgb(229, 240, 136);
text-align: center;
color: rgb(175, 167, 166);
border-top: 5px solid rgb(175, 167, 166);
overflow: hidden;
padding-top: 20px;
bottom: 0;
width: 100%;
height: 100px;
}
我遇到的问题是它会根据屏幕大小移动页脚。它不会一直呆在那里。
【问题讨论】:
-
您检查过official example 和tried something yourself 吗?在复制示例时,您到底在哪里卡住了?
-
你目前有什么代码?
标签: css footer sticky-footer