gpt4 book ai didi

html - 固定页脚的 CSS

转载 作者:技术小花猫 更新时间:2023-10-29 12:46:09 24 4
gpt4 key购买 nike

我有一个非常基本的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com