我在页面底部有一个包含在 php 中的页脚元素:
<footer>
<h5>Title</h5>
<h6>© Copyright 2012</h6>
</footer>
footer{
width:100%;
height:40px;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
background-color:#EEE;
text-align:center;
position:absolute;
bottom:0;
}
这会按预期将页脚与底部对齐。问题来自于页面主要部分中的数据是通过 AJAX 调用加载的,而页脚只是停留在添加 ajax 元素之前的位置。 movieBox 元素默认为空,并在返回 ajax 调用时填充多个 div。
<div id="movieBox"></div>
<br style="clear:both"/>
是否有解决此问题的纯 css 方法?还有其他方法吗?感谢您的帮助。
最佳答案
您绝对定位页脚,这意味着无论通过 AJAX 加载什么内容,它都将保留在同一个位置。你需要改变你的布局,这样你就不会依赖 position: absolute。
关于css - 添加 ajax 元素后定位的 div 元素不会流动/更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12746432/