zoukankan      html  css  js  c++  java
  • 商务通关闭效果

    <!DOCTYPE HTML>
    <html>
    <head>
    <title>商务通关闭效果</title>
    <meta name="description" content="商务通关闭效果(缩小到消失)" />
    </head>
    <body>
    <style>
    #w{width:450px;height:360px;margin:0 auto;border:1px solid #514654;background:url(http://swt.027abl.com/swtr2.gif) no-repeat center;display:block;}
    </style>
    <img id="w" src="http://swt.027abl.com/swtr2.gif" width="450" height="360" />
    <script>
    var oD=document.getElementById("w");
    var w=parseInt(getComputedStyle(oD,false).width);
    var h=parseInt(getComputedStyle(oD,false).height);
    //var h=Number(getComputedStyle(oD,false).height);//返回NaN
    oD.onclick=function(){
        setInterval("slow()",1);
    };
    function slow(){
        if(w>0 && h>0){
        w-=2.75;
        h-=2.2;
        //alert(w+"px");
        oD.style.width=w+"px";
        oD.style.height=h+"px";
        //alert(oD.style.width);
        }
        else{
        oD.style.display="none";
        }
        
    }
    </script>
    </body>
    </html>

     修改后:断点display:none ; 无需定义全局变量!

    <!DOCTYPE HTML>
    <html>
    <head>
    <title>商务通关闭效果</title>
    <meta name="description" content="商务通关闭效果(缩小到消失)" />
    </head>
    <body>
    <style>
    #w{width:450px;height:360px;margin:0 auto;border:1px solid #514654;background:url(http://swt.027abl.com/swtr2.gif) no-repeat center;display:block;}
    </style>
    <img id="w" src="http://swt.027abl.com/swtr2.gif" width="450" height="360" />
    <script>
    
    oD.onclick=function(){
    
    var oD=document.getElementById("w");
    var w=parseInt(getComputedStyle(oD,false).width);
    var h=parseInt(getComputedStyle(oD,false).height);
    //var h=Number(getComputedStyle(oD,false).height);//返回NaN
    var a=setInterval("slow()",1);
    clearInterval(a);
    };
    function slow(){
        if(w>0 && h>0){
        w-=2.75;
        h-=2.2;
        //alert(w+"px");
        oD.style.width=w+"px";
        oD.style.height=h+"px";
        //alert(oD.style.width);
        }
        else{
        oD.style.display="none";
            
        }
    }
    </script>
    </body>
    </html>

     兼容IE效果

    <!DOCTYPE HTML>
    <html>
    <head>
    <title>商务通关闭效果</title>
    <meta name="description" content="商务通关闭效果(缩小到消失)" />
    </head>
    <body>
    <style>
    #w{width:450px;height:360px;margin:0 auto;border:1px solid #514654;background:url(http://swt.027abl.com/swtr2.gif) no-repeat center;display:block;}
    </style>
    <img id="w" src="http://swt.027abl.com/swtr2.gif" width="450" height="360" />
    <script>
    var oD=document.getElementById("w");
    oD.onclick=function(){
    if(oD.currentStyle){
    var w=parseInt(oD.currentStyle.width);
    var h=parseInt(oD.currentStyle.height);
    }else{
    var w=parseInt(getComputedStyle(oD,false).width);
    var h=parseInt(getComputedStyle(oD,false).height);
    }
    var a=setInterval(function(){
    if(w>0 && h>0){
        w-=2.75;
        h-=2.2;
        oD.style.width=w+"px";
        oD.style.height=h+"px";
        }
        else{
        oD.style.display="none";
        clearInterval(a);    
        }
    
    },1);
    };
    
    </script>
    </body>
    </html>
  • 相关阅读:
    Python数值计算:一 使用Pylab绘图(2)
    Python数值计算:一 使用Pylab绘图(1)
    Gromacs处理amino acid residues小结
    实用正则表达式匹配和替换
    将Word转为带书签的PDF
    QT在windows下实现截屏操作并保存为png图片
    VMware虚拟机无法识别U盘解决方案
    C/C++/Qt 统计运行时间
    ffmpeg 中 swscale 的用法
    用qt代码怎样编写图片保存格式[qt4.6]
  • 原文地址:https://www.cnblogs.com/dream-w/p/4835311.html
Copyright © 2011-2022 走看看