1.    IE 滤镜动画设计
  2.    
  3.  <html> 
  4.     <head> 
  5.     <style> 
  6.         #bg{ 
  7.             width:90%; 
  8.             height:400px; 
  9.             margin:auto; 
  10.             background:black; 
  11.             color:white; 
  12.              
  13.         } 
  14.     </style> 
  15. </head> 
  16. <BODY> 
  17.     <center> 
  18.         <!-- 绝对定位的父容器如果不是绝对定位,那么它的坐标是相对于body的 --> 
  19.     <div id='bg' style='filter:progid:DXImageTransform.Microsoft.Gradient(gradienttype=1, startcolorstr=#ffffff, endcolorstr=#ffffff) alpha(opacity=255);position:absolute;left:15%;width:70%;'> 
  20.         <div id='xx' style='position:absolute;left:40%;'> 
  21.         <font id='x' color=white style="filter:shadow(strength=5,color=rgb(255,255,255)) DropShadow(color=#999999,offX=0,offY=0);width:1px;height:1px;font-family:Arial Black;font-weigth:bold;font-size:200pt;"> 
  22.  
  23.             X 
  24.         </font> 
  25.         </div> 
  26.         <font id='gun' color=white style="filter:alpha(opacity=0) shadow(strength=5,color=white);width:1px;height:1px;font-family:Arial Black;font-weigth:bold;font-size:150pt;"> 
  27.             Gun 
  28.         </font> 
  29.     </div> 
  30. </center> 
  31.     <script> 
  32.          var x = document.getElementById('x'); 
  33.          //1-2秒浮现出来,如果按1秒25frame算,每frame为40ms,颜色需要变化25次 
  34.          //从0 - 255 每次增加 255/25 色值10 
  35.          function change(start){ 
  36.             if(start<0)start=0
  37.                 //x.style.color = 'rgb('+start+','+start+','+start+')'; 
  38.                 //滤镜只支持16位颜色 
  39.                 var temp = start.toString(16); 
  40.                 temptemp = temp.length<2?0+temp:temp; 
  41.                 x.filters[0].color'#'+temp+temp+temp; 
  42.                 if(start==0){ 
  43.                     moveX(document.getElementById('xx').offsetLeft); 
  44.                     return; 
  45.                 } 
  46.                 setTimeout(function(){change(start-10)},100); 
  47.          } 
  48.           
  49.          change(255); 
  50.           
  51.          //10个frame完成 
  52.          function moveX(start){ 
  53.                     var xx = document.getElementById('xx'); 
  54.                     if(start<0)start=0
  55.                     with(xx.style){ 
  56.                         left=start+'px'; 
  57.                     } 
  58.                     if(start==0){ 
  59.                         changeBg(255); 
  60.                         return; 
  61.                     } 
  62.                     setTimeout(function(){moveX(start-30)},40); 
  63.                      
  64.          } 
  65.           
  66.          //渐变背景色,浮现Gun 
  67.          function changeBg(start){ 
  68.                     if(start<0)start=0
  69.                     var temp = start.toString(16); 
  70.                     temptemp = temp.length<2?0+temp:temp; 
  71.                     //改变X 
  72.                     x.style.color = 'rgb('+start+','+start+','+start+')'; 
  73.                     //改变背景 
  74.                     var bg = document.getElementById('bg'); 
  75.                     bg.filters[0].endcolorstr'#'+temp+temp+temp; 
  76.                     //浮现字符 
  77.                     var gun = document.getElementById('gun'); 
  78.                     gun.filters[0].opacity = 255-start; 
  79.                     if(start==0){ 
  80.                     changeGun(255); 
  81.                         return; 
  82.                     } 
  83.                     setTimeout(function(){changeBg(start-10)},10); 
  84.          } 
  85.           
  86.          //Gun渐变消失 
  87.          function changeGun(start){ 
  88.                     if(start<0)start=0
  89.                     //渐变消失字符 
  90.                     var gun = document.getElementById('gun'); 
  91.                     gun.filters[0].opacity = start
  92.                     if(start==0){ 
  93.                         //x.style.width='100%'
  94.                         //x.style.height='100%'
  95.                         setTimeout(function(){ 
  96.                             bgShake(50) 
  97.                         dispearBg(255); 
  98.                         },500); 
  99.                         return; 
  100.                     } 
  101.                     setTimeout(function(){changeGun(start-10)},40); 
  102.          } 
  103.           
  104.          //X背景闪动,范围 x=y,在 +-50 --- +-100之间 
  105.          function bgShake(times){ 
  106.             if(times<0){ 
  107.                 //var bg = document.getElementById('bg'); 
  108.                 //bg.style.display='none'
  109.                 return; 
  110.             } 
  111.                     x.filters[1].offXrand()[0]?rand()[1]*-1:rand()[0]; 
  112.                     x.filters[1].offYrand()[0]?rand()[1]*-1:rand()[0]; 
  113.                     setTimeout(function(){bgShake(times-1)},80); 
  114.          } 
  115.           
  116.          //渐变背景消失 
  117.          function dispearBg(start){ 
  118.                     if(start<0)start=0
  119.                     //改变背景 
  120.                     var bg = document.getElementById('bg'); 
  121.                     bg.filters[1].opacitystart
  122.                     if(start==0){ 
  123.                          
  124.                         return; 
  125.                     } 
  126.                     setTimeout(function(){dispearBg(start-10)},40); 
  127.          } 
  128.           
  129.           
  130.          //返回正负和数值 
  131.          function rand(){ 
  132.                 var temp = Math.random()*100; 
  133.                 var positive = temp<50?true:false; 
  134.                 temp = positive?temp+50:temp; 
  135.                 return [positive,temp]; 
  136.          } 
  137.     </script> 
  138. <!-- 
  139. <div id='bg'> 
  140.     <font color=black style="filter:shadow(color=#black);width:100px;height:200px;font-family:Arial Black;font-weigth:bold;font-size:200pt;">X</font> 
  141.     <font style="filter:shadow(color=#dddddd);width:100px;height:100px;font-family:Arial Black;font-weigth:bold;font-size:200pt;">Gun</font> 
  142. </div> 
  143. --> 
  144.  
  145. </body> 
  146. </html>