设置"位置:固定"在IE浏览器中引起闪烁,但在chrome,firefox,safari中也是如此

时间:2015-07-27 07:47:59

标签: internet-explorer scroll fixed flicker

当我想在向下滚动的同时修复一个表的thead时,它在IE11中闪烁,但在其他人中它表现得很好。 因为它只是由位置:固定'引起的,这里只是javascript代码。

window.onload = function () {
        var tableHead = document.getElementById("tableHead");
        var tableBody = document.getElementById("tableBody");
        var wired = document.getElementById("wired");
        var divLeft = document.getElementById("divLeft");
        var divTop = document.getElementById("divTop");
        window.onscroll = function () {
            var scrollTop = 0;
            scrollTop = document.body.scrollTop;
            if (scrollTop > 22) {
                tableBody.style.display = "block";
                tableHead.style.marginTop = "-23px";
                tableHead.style.position = "fixed";
                tableHead.style.zIndex = "99999";
                divLeft.style.position = "";
            } else {
                tableHead.style.display = "block";
                tableHead.style.position = "";
                tableHead.style.zIndex = "0";
                tableHead.style.marginTop = "0";
                tableBody.style.display = "block";
            }
}

0 个答案:

没有答案