回应调整大小

时间:2016-02-27 07:53:08

标签: javascript html css responsive-design

我有一个粘性页脚,需要在网站内容增长时重新定位。目前,当我的textarea增长到一定程度时,它只会使页脚下溢,并且该页脚保持原样。

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

1 个答案:

答案 0 :(得分:2)

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>