JS基本动画

        <style type="text/css">
            .color_red {
                background: red;
            }
            div 
            {
                position: absolute;
                top: 0;
                width: 40px;
                height: 40px;
            }
        
        </style>
        <div  class="color_red" id="divShow">
        
        </div>
        <script language="javascript"> 
                
            function Move() {
                var oM = $("divShow").style, t = 0, c = 10;
                clearTimeout(Move._t);
                function _run() {
                    if (t <= 500) {
                        t++;
                        oM.left = Math.ceil(10 * (t / 10)) + "px";
                        Move._t = setTimeout(_run, 10);
                    } else {
                        oM.left = "0px";
                    }
                }
                _run();
            }
            var $ = function (id) {
                return "string" == typeof id ? document.getElementById(id) : id;
            };
            Move();
        </script>    

 

posted @ 2013-11-22 11:05  xyzhuzhou  阅读(250)  评论(0编辑  收藏  举报