响应调整大小

Respond to resize

本文关键字:调整 响应      更新时间:2023-09-26

我有一个粘性页脚,当网站内容增长时需要重新定位。目前,当我的文本区域增长到某个点时,它只是在页脚下溢出,并且该页脚保持原样。

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

Ryan Fait 的粘性页脚:

* {
    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>