简体   繁体   English

在div底部获得页脚

[英]Get footer at bottom of div

I have a div that I would like to put a fixed position footer on. 我有一个div,我想放置一个固定位置的页脚。 It's very simple and light. 非常简单轻巧。 When I add the bottom: 0px; position: fixed; 当我添加bottom: 0px; position: fixed; bottom: 0px; position: fixed; to keep it at the bottom of the div, it goes to the bottom of the page and it's not even fixed. 要将其保留在div的底部,它会转到页面的底部,甚至没有固定。 I'm usually pretty good with this stuff, but this has just driven me crazy. 我通常对这些东西非常满意,但是这让我发疯了。 Here is a link to a JSFiddle with the code. 是带有代码的JSFiddle的链接。 Please tell me what you think is wrong. 请告诉我您的想法是错误的。

Position fixed is relative to the whole document. 固定位置是相对于整个文档的。 Set the parent relative and the footer absolute: 设置父级亲戚和页脚的绝对值:

DEMO 演示

.post-contain { position: relative; }
.author-box {   position: absolute; }

Also why are you setting the p in the footer relative? 另外,为什么还要在页脚相对中设置p? See the updated demo. 请参阅更新的演示。

position: fixed is relative to the page. 位置:固定于页面。

What you really want is to set .post-contain { position: relative } .author-box { position: absolute } 您真正想要的是设置.post-contain {位置:相对} .author-box {位置:绝对}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM