CSS3 box-shadow blur in IE9

后端 未结 4 2278
走了就别回头了
走了就别回头了 2021-01-01 22:37

Has anyone else noticed that IE9\'s \"standard\" implementation of CSS box-shadow differs from other browsers? Whenever I use box-shadow and set a blur value, IE9 seems to r

4条回答
  •  猫巷女王i
    2021-01-01 22:59

    I also had this problem and solved it for myself with this script (using jQuery).

    Please note this is experimental and I haven't tested performance. Also: You have to run it again if you add elementss to your dom which has box-shadow. I guess that could be solved using a htc-file instead.

    $(function(){
        fixBoxShadowBlur($('*'));
    });
    
    function fixBoxShadowBlur(jQueryObject){
        if($.browser.msie && $.browser.version.substr(0, 1) == '9'){
            jQueryObject.each(function(){
                boxShadow = $(this).css('boxShadow');
                if(boxShadow != 'none'){
                    var bsArr = boxShadow.split(' ');
                    bsBlur = parseInt(bsArr[2]) || 0;
                    bsBlurMeasureType = bsArr[2].substr(("" + bsBlur).length);
                    bsArr[2] = (bsBlur * 2) + bsBlurMeasureType;
                    $(this).css('boxShadow', bsArr.join(' '));
                }
            });
        }
    }
    

提交回复
热议问题