html - 实现 'sticky footer' 时浏览器之间的行为不一致

标签 html css internet-explorer footer sticky

我已经记不清我读过多少篇关于这个主题的文章了。坦率地说,我不是 CSS 专家。我预订了一个在 Firefox 和 Chrome 中完美运行但在 IE9 及更高版本中失败的“粘性页脚”。 (它在IE中的位置随浏览器窗口的高度而变化。在其他浏览器中它固定在底部。)

css如下:

#footer {
    position:relative;
    margin-top: -150px; 
    height: 150px;
    clear: both;
    bottom:0px;
}

html(母版页中)如下:

 <footer>
     <div id="footer">
        <div style="margin: auto;">

        </div>
        <br />
        <div style="text-align: center; margin: auto; margin-left: auto; 
             margin-right: auto; width: 100%; margin-bottom: auto">
               <p>&copy; Copywrite blurb and date here</p>
         </div>
      </div>
 </footer>

建议?

最佳答案

我也有点菜鸟,但我觉得是“position:relative”可能会弄乱您的代码。您的页脚是否包裹在另一个 div 中?

也许尝试将您的页面包裹在高度为 100% 的内容 div 中,然后相对于此而不是页面定位。

或者将 body 和 html 设置为 height: 100%。页脚周围元素的当前高度是多少?

只是抛出一些想法。 :)

关于html - 实现 'sticky footer' 时浏览器之间的行为不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22623487/

相关文章:

javascript - IE window.open 在第二个 session 上打开一个具有第一个 session ID 的窗口

internet-explorer - Haml中的“[ !IE]”条件注释

Internet Explorer 中的 Javascript 命名函数表达式

html - float CSS后Div崩溃

javascript - 单击时更改 div 样式不起作用

html - 无法加载字体

css - 停止 ExtJs 样式元素

html - CSS 问题页眉和页脚不保持高度

html - 为什么我在集成 Facebook Open Graph 时收到错误 "Required Property Missing"?

html - 需要将父文档的 css 获取到 iframe