我有一个非常基本的 HTML 页面。代码如下所示:
<body>
<header style="min-height: 255px;">
</header>
<article style="padding-bottom: 60px; width: 900px; margin: 0 auto;">
Body text goes here.
</article>
<footer style="position: absolute; bottom: 0px; width: 100%; height: 60px; background-color: black;">
Copyright information
</footer>
</body>
通常,我的正文相当大。文本足够大,需要滚动条。看起来页脚位于文本的顶部,朝向底部。然后,当我向下滚动时,页脚不会保持固定。我做错了什么?
谢谢
最佳答案
你的页脚需要 position:fixed;
:
<body>
<header style="min-height: 255px;">
</header>
<article style="padding-bottom: 60px; width: 900px; margin: 0 auto;">
Body text goes here.
</article>
<footer style="position: fixed; bottom: 0px; width: 100%; height: 60px; background-color: black;">
Copyright information
</footer>
</body>
关于html - 固定页脚的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13788357/