非粘性页脚 CSS 有帮助吗?

发布于 2024-12-10 14:05:10 字数 189 浏览 0 评论 0原文

我希望我的页脚粘在页面的底部,所以我使用了

position: absolute;
bottom: 0px;

将其带到底部的方法,但是当您重新调整窗口大小且窗口很小时,页脚会与页面上的其他所有内容重叠。

如何将其保留在底部,然后如果页面太小,则不显示页脚(不要让它与其他内容重叠)

I want my footer to stick to the bottom of the page, so I used a

position: absolute;
bottom: 0px;

that brings it to the bottom, however when you re-size your window and it is small, the footer is overlapping everything else on the page.

How do you keep it at the bottom and then if the page is too small, just don't show the footer (not let it overlap other content)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

維他命╮ 2024-12-17 14:05:10

您可以查看一些“粘性页脚 css”技术,例如:

http://www.cssstickyfooter.com/

谢谢

You can have a look at some "sticky footer css" techniques like:

http://www.cssstickyfooter.com/

Thanks

多孤肩上扛 2024-12-17 14:05:10

您所描述的是粘性页脚。除了使用 javascript 之外,这是一件非常复杂的事情,并且在许多情况下是非常特定于实现的(仅在其构建的网站上工作:P)。我链接的那个网站有一种方法,可能适合你,也可能不适合你。当我想这样做时,这对我来说不起作用,但这一切都取决于具体情况。

What you are describing is a Sticky Footer. This, apart from using javascript, is a very complicated thing to do and in many cases is very implementation specific (will only work on the site it's built on :P). That site I linked has a way that may or may not work for you. It didn't work for me when I wanted to do this, but it all depends on the specific circumstances.

傲娇萝莉攻 2024-12-17 14:05:10

要让页脚缩小或在浏览器较小时以其他方式表现不同,您需要由加载和调整大小事件(至少)触发的javascript来检查主页的高度,并且当低于特定大小时会修改页脚的属性。

以我能想象的任何方式单独使用 CSS 都是不可能的。

To have the footer shrink or otherwise act differently when the browser is small, you'd need javascript that is triggered by load and resize events (at least) that would check the height of the main page, and when under a specific size would modify the properties of the footer.

It is not possible with CSS alone in any way I can imagine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文