多亏了参与 stackoverflow 的优秀人员,我认为我可以让这个布局工作,see here .不幸的是,虽然我在 IE7 中发现了一个问题(还没有在 IE6 中检查过!)——页脚与内容重叠
我已经把网站 up on my development server here .我希望我不必从头开始就可以让它工作,而 CSS 会来拯救...
最佳答案
将页脚推到视口(viewport)底部的一种快速简便的方法是使用以下 JavaScript。诀窍是有一个单独的容器和一个页脚,并在脚本中引用这些 ID:
在头部标签中:
<脚本类型="文本/javascript">
<!--
window.onload = function() {
设置页脚();
}
window.onresize = function() {
设置页脚();
}
//-->
脚本>
和脚本:
try {
document.execCommand("BackgroundImageCache", false, true);
}
catch (err) {
}
function getWindowHeight() {
var windowHeight = 0;
if (typeof (window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
}
else {
if (document.body && document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}
function setFooter() {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
var contentHeight = document.getElementById('container').offsetHeight;
var footerElement = document.getElementById('footerContainer');
var footerHeight = footerElement.offsetHeight;
if (windowHeight - (contentHeight + footerHeight) >= 0) {
footerElement.style.position = 'relative';
footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
}
else {
footerElement.style.position = 'static';
}
}
}
}
关于css - IE7 中的页脚重叠内容? :(,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1541623/