html - 粘性页脚未放置在底部

标签 html css cross-browser footer sticky-footer

我只是对页脚进行一些快速更改。

页脚需要有粘性,我按照A List Apart描述的方法进行操作尝试让页脚留在底部的方法,但它似乎只偏离了一点点。

html, body {
height: 100%;
 }
#container {
position: relative;
min-height: 100%;
}

<div id="container">
    <div id="content">...</div>
    <div id="footer">...</div>
</div>

最佳答案

我总是使用 CSSStickyFooter method .

  • HTML,一个基本框架

    <div id="wrap">
    
        <div id="main">
    
        </div>
    
    </div>
    
    <div id="footer">
    
    </div>          
    
  • CSS,这只是一个片段

    * {margin:0;padding:0;} 
    
    html, body {height: 100%;}
    
    #wrap {min-height: 100%;}
    
    #main {overflow:auto;
        padding-bottom: 180px;}  /* must be same height as the footer */
    
    #footer {position: relative;
        margin-top: -180px; /* negative value of footer height */
        height: 180px;
        clear:both;} 
    

关于html - 粘性页脚未放置在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14877482/

相关文章:

javascript - 切换具有多个值的选择器 CSS

php - Mysql数据库只进入一次

javascript - 如何将 linenums 动态添加到 Google Code prettify 中?

jquery - 当鼠标离开触发器并向下滑动内容时,如何对向下滑动的内容进行编码以向上滑动?

html - 如何使用 CSS 或 JavaScript 禁用文本选择?

javascript - 使用 jquery 的 addClass 方法覆盖样式表

html - 如何避免在 CSS float 中换行

css - 用百分比保持/缩放 DIV 比率

html - Opera css 错误,web 应用程序显示不正确

javascript - 使用ajax在html中加载html文件时出现的问题