我的脚注有一个粘性,需要在网站内容增长时重新定位。当前,当我的文本区域增长到一定程度时,它只会使页脚下溢,而该页脚将保持原样。

响应高度调整元素的最佳方法是什么?我看过一些使用动画帧等的东西。但是我要做的就是每次触发调整大小事件时都重新计算页脚的位置。

最佳答案

瑞安·菲特(Ryan Fait)的sticky footer



* {
    margin: 0;
}

html,
body {
    height: 100%;
}

main {
    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 */
}

footer {
    height;
    155px;
    background: gray;
}

textarea {
    height: 100px;
    width: 200px;
}

<main>
    <textarea></textarea>
    <div class="push"></div>
</main>
<footer>

</footer>

10-05 20:53
查看更多