求一个可以满足ie 7 8 中Div 阴影效果的实现方法 不要box-shadow 不要pie.js 谢谢 各位大侠

解决方案 »

  1.   


    <style>
    div{width:100px; height:100px;background:#d07575;}
    </style>
    <div id="box"></div>
    <script>
    function getCss(o,key){
    return o.currentStyle[key]
    }
    function addShadow(_box){
    if(document.all){//IE
    var getWidth,getHeight,createBox,nowHtml,defaultHTML;
    getWidth = getCss(_box,"width");
    getHeight = getCss(_box,"height");
    _box.style.cssText += ";position:absolute;z-index:1;top:0;left:0;";
    nowHtml = _box.outerHTML;
    defaultHTML = '<div  id="creatediv">' + nowHtml +'</div>';
    _box.outerHTML = defaultHTML;
    var ss = document.getElementById("creatediv");
    ss.style.cssText += ";position:relative;width:"+getWidth+";height:"+getHeight;
    createBox  = document.createElement("em");
    createBox.style.cssText = ";position:absolute; z-index:0;bottom:-10px; right:-10px; background:#000;display:block;width:100%;height:100%;filter:progid:DXImageTransform.Microsoft.Blur(pixelradius=5); ";
    ss.appendChild(createBox);
    }else{//chrome FF ...
    _box.style.cssText = "-webkit-box-shadow:5px 5px 5px #000;-moz-box-shadow:5px 5px 5px #000;box-shadow:5px 5px 5px #000;"
    }
    }
    var thisID = document.getElementById("box");
    addShadow(thisID)
    </script>尝试了这种方法 基本你要的效果出来了  实用性不大 。 你看看吧 具体颜色值及模糊程度 可以在createBox.style.cssText里面的CSS那调整。没用参数 写死了。
      

  2.   

    参考下http://www.zhangxinxu.com/wordpress/2010/07/css%e5%ae%9e%e7%8e%b0%e8%b7%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e7%9a%84box-shadow%e7%9b%92%e9%98%b4%e5%bd%b1%e6%95%88%e6%9e%9c2/