非粘性页脚 CSS 有帮助吗?
我希望我的页脚粘在页面的底部,所以我使用了
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以查看一些“粘性页脚 css”技术,例如:
http://www.cssstickyfooter.com/
谢谢
You can have a look at some "sticky footer css" techniques like:
http://www.cssstickyfooter.com/
Thanks
您所描述的是粘性页脚。除了使用 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.
要让页脚缩小或在浏览器较小时以其他方式表现不同,您需要由加载和调整大小事件(至少)触发的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.