css - IE7 中的页脚重叠内容? :(

标签 css internet-explorer-7 cross-browser

多亏了参与 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/

相关文章:

css ie7 在行之间添加额外的空间

jquery - 如果 margin 和 padding 为 0,为什么 imgs 之间有空格?

css - Firefox CSS选择OPTION样式

javascript - 可能是一个快速的 : Escape problems (I think) in an . innerHTML 调用

javascript - 使用 javascript 返回上一页

jquery - 幻灯片导航菜单

javascript - 使用 google Recaptcha 形式的 undefined variable ?

html - 为什么我不能为按钮内的文本设置样式?

css - 主容器上带有 flexgrow 的水平可滚动 div

html - 将IE7旋转90度