CSS 固定底部对齐的 Div

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/882104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:36:32  来源:igfitidea点击:

Fixed Bottom Aligned Div

css

提问by olemarius

I need a footer in the bottom of a page, which is overlaps any content that will make the page scroll. Also, when scrolling down, it the footer still need to stay there.

我需要在页面底部有一个页脚,它与任何会使页面滚动的内容重叠。此外,向下滚动时,页脚仍然需要留在那里。

Is this possible with css only working for IE6+ ?

仅适用于 IE6+ 的 css 是否可以做到这一点?

回答by a programmer

Recently I used the following style:

最近我使用了以下样式:

div.BottomDisclaimer
{
  z-index:100;
  position:fixed;
  bottom:0px;
  border-top-style: solid;
  border-top-width: 1pt;
  padding-top: 4px;
}

回答by peirix

Do a quick google search for CSS footer, and you'll find plenty solutions. But most solutions seem to work like this:

在谷歌上快速搜索 CSS 页脚,你会找到很多解决方案。但大多数解决方案似乎是这样工作的:

<body>
  <div id="wrapper">
     Main content
  </div>
  <div id="footer">
     Footer content
  </div>
</body>

and then applying css:

然后应用css:

body, html { height: 100% }
#wrapper { height: 100% }
#footer {
  height: 150px;
  margin-top: -150px;
}

回答by Moayad Mardini

EDIT : because IE6 doesn't support position:fixed;, here's a good workaround.

编辑:因为 IE6 不支持 position:fixed;,这是一个很好的解决方法

回答by Paul Fisher

For IE6, it's not possible to use position:fixed. You can use Dean Edwards' IE7 libraryto get that behavior if you want.

对于 IE6,无法使用position:fixed. 如果需要,您可以使用 Dean Edwards 的IE7 库来获得该行为。