• 仿360开机效果


    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
        <style>
    .box{
                322px;
                position: fixed;
                bottom:0;
                right:0;
            }
            span{
                position: absolute;
                top:0;
                right:0;
                30px;
                height: 20px;
                cursor: pointer;
            }
            .box img{
                vertical-align: top;
            }
        </style>  
    </head>
    <body>
    <div class="box" id="box">
        <span></span>
        <div class="hd" id="hd">
            <img src="images/t.jpg" alt=""/>
        </div>
        <div class="bd" id="bt">
            <img src="images/b.jpg" alt=""/>
        </div>
        <script type="text/javascript" src="animate.js"></script>
        <script type="text/javascript">
            function $(id){
                return document.getElementById(id);
            }
             var close =$('box').children[0];
             close.onclick=function(){
               animate($('bt'),{'height': 0},function(){
                     animate($('box'),{'width': 0})
                });
             }
        </script>
    </div>
    </body>
    </html>
     -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    animate.js
     
     
    /*
    * @Author: Administrator
    * @Date:   2018-12-15 20:21:14
    * @Last Modified by:   Administrator
    * @Last Modified time: 2018-12-13 20:04:17
    */
    //获取obj的css样式
    function getStyle(obj, attr){
        if(window.getComputedStyle){//正常浏览器支持的api(chrome,IE9+,firefox)
            return window.getComputedStyle(obj, null)[attr];
        }else{//IE6/7/8/支持的api
            return obj.currentStyle[attr];
        }
    }
    //缓动框架
    function animate(obj, json){
        clearInterval(obj.timer);
        obj.timer = setInterval(function(){
            //拿2当前样式得值,计算步长,设置obj的改属性样式的值 =当前样式的值+步长+px
            var current=0;
            var step=0;
            var flag=true;
            for (var attr in json) {
             current = parseInt(getStyle(obj, attr));//获取样式的值,并且切掉单位,转换成number
             step = (json[attr]- current) / 10;//计算步长
             step = step > 0 ? Math.ceil(step) : Math.floor(step);//把步长取整
             obj.style[attr] = current + step + 'px';   
            //如果动画已经做完,清除定时器
            if(current != json[attr]){
                flag=false;//如果有任何一个属性没有到达终点,就把flag置为flase
                }
            }
            if(flag){
                clearInterval(obj.timer);
            }
        }, 20);
    }
     
     
     
  • 相关阅读:
    BaseDao
    url中文参数解决方案
    Ajax实现步骤和原理
    在服务器端使用文件时的路径解决方案
    用户验证登录拦截器
    jenkins环境搭建
    gitlab环境搭建
    nexus3.X环境搭建
    base64文件大小计算
    JVM远程调试功能
  • 原文地址:https://www.cnblogs.com/mmit/p/11257786.html
Copyright © 2020-2023  润新知