zoukankan      html  css  js  c++  java
  • 动画效果打开层 关闭层

    http://bbs.blueidea.com/thread-2844175-1-1.html





    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>DOM_text01</title>
    <style type="text/css">
    body,span,div,td
    {font-size:12px;line-height:1.5em;color:#849BCA;}
    #bodyL
    {
        float
    :left;
        width
    :84px;
        margin-right
    :2px;
    }

    a.od
    {
        width
    :80px;
        height
    :25px;
        line-height
    :25px;
        text-align
    :center;
        font-weight
    :bold;
        border
    : 2px solid #849BCA;    
        display
    :block;
        color
    :#547BC9;
        float
    :left;
        text-decoration
    :none;
        margin-top
    :2px;
    }

    a.od:link
    {
        background
    :#EEF1F8;
    }

    a.od:visited
    {
        background
    :#EEF1F8;
    }

    a.od:hover
    {
        background
    :#EEE;
    }

    a.od:active
    {
        background
    :#EEE;
    }

    #fd
    {    
        width
    :500px;
        height
    :200px;
        background
    :#EDF1F8;    
        border
    : 2px solid #849BCA;
        margin-top
    :2px;
        margin-left
    :2px;
        float
    :left;
        overflow
    :hidden;
        position
    :absolute;
        left
    :0px;
        top
    :0px;
        cursor
    :move;
        float
    :left;
        
    /*filter:alpha(opacity=50);*/
        
    }

    .content
    {
        padding
    :10px;
    }

    .hidden
    {display:none;}
    </style>
    </head>
    <body>
    <div id="bodyL">
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
        
    <!--<a href="#" class="od" id="aaa" onclick = "document.getElementById('bbb').display = 'block';this.style.display='none';show('fd');return false;">[打开层]</a>
        <a href="#" class="od" id="bbb" onclick = "document.getElementById('aaa').display = 'block';this.style.display='none';closeed('fd');return false;">[关闭层]</a>
    -->
        
    <input type="button" value="打开" id="sw_bt" onclick="sw(this,'fd');"/>
    </div>    
    <div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
        
    <div class="content">移动层</div>
    </div>
        
    <script type="text/javascript">
    function sw(o,id){
        
    if (o.value=="打开"){
            o.value
    ="关闭";
            show(id)
        }

        
    else{
            o.value
    ="打开"
            closeed(id)
        }

    }

        
    var prox;
        
    var proy;
        
    var proxc;
        
    var proyc;
        
    function show(id){/*--打开--*/
            clearInterval(prox);
            clearInterval(proy);
            clearInterval(proxc);
            clearInterval(proyc);
            
    var o = document.getElementById(id);
            o.style.display 
    = "block";
            o.style.width 
    = "1px";
            o.style.height 
    = "1px"
            prox 
    = setInterval(function(){openx(o,500)},10);
        }
        
        
    function openx(o,x){/*--打开x--*/
            
    var cx = parseInt(o.style.width);
            
    if(cx < x)
            
    {
                o.style.width 
    = (cx + Math.ceil((x-cx)/5)) +"px";
            }

            
    else
            
    {
                clearInterval(prox);
                proy 
    = setInterval(function(){openy(o,200)},10);
            }

        }
        
        
    function openy(o,y){/*--打开y--*/    
            
    var cy = parseInt(o.style.height);
            
    if(cy < y)
            
    {
                o.style.height 
    = (cy + Math.ceil((y-cy)/5)) +"px";
            }

            
    else
            
    {
                clearInterval(proy);            
            }

        }
        
        
    function closeed(id){/*--关闭--*/
            clearInterval(prox);
            clearInterval(proy);
            clearInterval(proxc);
            clearInterval(proyc);        
            
    var o = document.getElementById(id);
            
    if(o.style.display == "block")
            
    {
                proyc 
    = setInterval(function(){closey(o)},10);            
            }
            
        }
        
        
    function closey(o){/*--打开y--*/    
            
    var cy = parseInt(o.style.height);
            
    if(cy > 0)
            
    {
                o.style.height 
    = (cy - Math.ceil(cy/5)) +"px";
            }

            
    else
            
    {
                clearInterval(proyc);                
                proxc 
    = setInterval(function(){closex(o)},10);
            }

        }
        
        
    function closex(o){/*--打开x--*/
            
    var cx = parseInt(o.style.width);
            
    if(cx > 0)
            
    {
                o.style.width 
    = (cx - Math.ceil(cx/5)) +"px";
            }

            
    else
            
    {
                clearInterval(proxc);
                o.style.display 
    = "none";
            }

        }
        
        
        
        
    /*-------------------------鼠标拖动---------------------*/    
        
    var od = document.getElementById("fd");    
        
    var dx,dy,mx,my,mouseD;
        
    var odrag;
        
    var isIE = document.all ? true : false;
        document.onmousedown 
    = function(e){
            
    var e = e ? e : event;
            
    if(e.button == (document.all ? 1 : 0))
            
    {
                mouseD 
    = true;            
            }

        }

        document.onmouseup 
    = function(){
            mouseD 
    = false;
            odrag 
    = "";
            
    if(isIE)
            
    {
                od.releaseCapture();
                od.filters.alpha.opacity 
    = 100;
            }

            
    else
            
    {
                window.releaseEvents(od.MOUSEMOVE);
                od.style.opacity 
    = 1;
            }
            
        }

        
        
        
    //function readyMove(e){    
        od.onmousedown = function(e){
            odrag 
    = this;
            
    var e = e ? e : event;
            
    if(e.button == (document.all ? 1 : 0))
            
    {
                mx 
    = e.clientX;
                my 
    = e.clientY;
                od.style.left 
    = od.offsetLeft + "px";
                od.style.top 
    = od.offsetTop + "px";
                
    if(isIE)
                
    {
                    od.setCapture();                
                    od.filters.alpha.opacity 
    = 50;
                }

                
    else
                
    {
                    window.captureEvents(Event.MOUSEMOVE);
                    od.style.opacity 
    = 0.5;
                }

                
                
    //alert(mx);
                //alert(my);
                
            }
     
        }

        document.onmousemove 
    = function(e){
            
    var e = e ? e : event;
            
            
    //alert(mrx);
            //alert(e.button);        
            if(mouseD==true && odrag)
            
    {        
                
    var mrx = e.clientX - mx;
                
    var mry = e.clientY - my;    
                od.style.left 
    = parseInt(od.style.left) +mrx + "px";
                od.style.top 
    = parseInt(od.style.top) + mry + "px";            
                mx 
    = e.clientX;
                my 
    = e.clientY;
                
            }

        }

        
        
    </script>
    </body>
    </html>
  • 相关阅读:
    npm 出现npm ERR! ERESOLVE unable to resolve dependency tree的错误
    Linux基础06 软链接, 硬链接, 查看磁盘状态df, 文件编辑vim(视图模式[批量注释]), 对比文件, 特殊符号, 显示ip地址命令ip, ifconfig, hostname, sed替换命令, awk取列命令
    Linux基础08 组的基本管理, 组的增删改, shell的分类, 环境变量的加载顺序, 登录显示动画, 切换用户su , 用户提权sudo, sudo企业案例
    Linux基础07 用户管理, 用户相关命令(创建, 修改, 删除), 用户创建配置文件, 命令提示符问题, 查看用户登录, 设置用户密码(设置随机复杂密码)
    在Linux上安装Python3
    WRI$_ADV_OBJECTS表过大,导致sysaux表空间不足
    优化器统计跟踪(SYS.EXP_HEAD$ SYS.EXP_OBJ$ SYS.EXP_STAT$不)导致表空间 SYSAUX不断增长
    使用 yapitotypescript 生成接口响应数据的 TS 类型声明
    git 忽略文件提交的几种姿势
    android项目和model存在同一个类调用时解决方法 L
  • 原文地址:https://www.cnblogs.com/CB/p/1146939.html
Copyright © 2011-2022 走看看