CSS粘脚;它是如何工作的?

时间:2015-03-31 15:23:50

标签: css

我已复制Ryan Fait's sticky footer。为清晰起见,这是CSS和HTML:

<body>

    <div class="wrapper">

    // Content

        <div class="push"></div>

    </div>

    <div class="footer">
        <p>Lorem ipsum</p>
    </div>

</body>

CSS:

html, body {
    height: 100%;
}
.wrapper {
    min-height: 100%;
    height: auto !important; /* This line and the next line are not necessary unless you need IE6 support */
    height: 100%;
    margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
    height: 155px; /* .push must be the same height as .footer */
}

正如您所看到的,它运作良好。我不明白的是,高度(注意:高度,而不是最小高度)是如何为body明确设定的,但它仍然超出这个值以容纳内容?

我希望我的问题很明确......

编辑:关于this answer的第二条评论似乎表明这不应该发生。

0 个答案:

没有答案