html - 粘性页脚,页脚和页面底部之间的间隙很小

标签 html css

我正在使用粘性页脚。我注意到在内容没有完全到达底部的页面上,页脚和页面底部之间有一个小间隙。

带有页脚空白的短内容示例:http://karenrubkiewicz.com/martin/published.html 没有页脚间隙的长内容示例:http://karenrubkiewicz.com/martin/people.html

下面是我的代码。 提前致谢!

HTML

<div class="wrapper">

SITE CONTENT HERE

<div class="push"></div>
</div> <!-- END WRAPPER -->

    <section id="footer">
    <div class="left">
        <li><a href="about.html">[about]</a></li>
        <li><a href="contact.html">[contact]</a></li>
        <li><a href="pdf.html">[pdf]</a></li>
        <li><a href="imprint.html">[Imprint]</a></li>
    </div>

    <div class="right">
        <li><a href="http://www.linkedin.com/home" target="_blank"><div class="linkedin"></div></a></li>
        <li><a href=" http://martinkess.tumblr.com/" target="_blank"><div class="tumblr"></div></a></li>
        <li><a href="https://www.behance.net/martinkess" target="_blank"><div class="behance"></div></a></li>
        <li><a href="https://www.facebook.com/martin.kess.7?fref=browse_search" target="_blank"><div class="facebook"></div></a></li>
    </div>
 </section>

CSS

html, body{
height:100%;
}

body{
overflow-x:hidden;
}

.wrapper {
overflow-x:hidden;
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -50px; /* the bottom margin is the negative value of the footer's height */
}

#footer .push {
height: 50px; /* .push must be the same height as .footer */
}

#footer{
position: absolute;
height: 50px;
left:0;
width:100%;
min-width:1300px;
background:#000;}

最佳答案

你在 body 上还有余量。你应该添加:

body{
    margin:0;
}

我建议你放一些CSS重置代码。统一元素的通用浏览器设置(这也可以防止这种情况)。

关于html - 粘性页脚,页脚和页面底部之间的间隙很小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25344507/

相关文章:

html - <img> 弄乱了容器大小并破坏了布局

javascript - 显示 :none defaulting width 的 HTML 元素

jquery - 如何使用Jquery制作多个弹出窗口

css - 我在 CSS 定义中设置操作的顺序重要吗?

html - 缩放时菜单元素跳跃

jquery - Twitter Bootstrap 模态 : make width and height the same size as user's max resolution

javascript - replaceWith 替换所有文本而不是仅空字符串

javascript - 当用户点击时启动 flash 游戏

css - 避免拉伸(stretch)图像(css、wordpress)

html - 字段集宽度父级的 100%