IE7 Z-Index Layering Issues

后端 未结 11 770
执念已碎
执念已碎 2020-11-22 11:31

I\'ve isolated a little test case of IE7\'s z-index bug, but don\'t know how to fix it. I have been playing with z-index all day long.

Wha

11条回答
  •  不思量自难忘°
    2020-11-22 11:37

    If the previously mentioned higher z-indexing in parent nodes wont suit your needs, you can create alternative solution and target it to problematic browsers either by IE conditional comments or using the (more idealistic) feature detection provided by Modernizr.

    Quick (and obviously working) test for Modernizr:

    Modernizr.addTest('compliantzindex', function(){
        var test  = document.createElement('div'),
            fake = false,
            root = document.body || (function () {
                fake = true;
                return document.documentElement.appendChild(document.createElement('body'));
            }());
    
        root.appendChild(test);
        test.style.position = 'relative';
        var ret = (test.style.zIndex !== 0);
        root.removeChild(test);
    
        if (fake) {
            document.documentElement.removeChild(root);
        }
    
        return ret;
    });
    

提交回复
热议问题