zoukankan      html  css  js  c++  java
  • js 动画效果代码,主要运用setTimeout

    代码只能对以px为单位的样式进行改变。

    js Code:

                function animate(ele,name,from,to,time) {
                    time = time ||800;
                    var interval,count,step,now;
                    interval = 60;
                    count =Math.round(time/interval);
                    step = Math.round((to-from)/count);
                    now = from;
                    var style = document.getElementById(ele).style;
                    function go() {
                        count--;
                        now = count?now+step:to;
                        style[name] = now + "px";
                        if(count) {
                            setTimeout(go,interval);
                        }
                    }
    
                    style[name] = from + 'px';
                    setTimeout(go,interval);
                }

    html Code:

            <p >
                <span id ='s1'>goole!!!!!goole</span>
            </p>
            <input type="button" value="changeSize" onclick="animate('s1','font-size',9,50,1000)">
  • 相关阅读:
    redis哨兵高可用
    数据库主从搭建
    docker 补充
    docker 进阶操作
    docker 简介
    数据可视化(Matplotlib)
    数据操作
    pandas练习
    Pandas简介
    python mysql utf-8 latin
  • 原文地址:https://www.cnblogs.com/xiashengwang/p/2578796.html
Copyright © 2011-2022 走看看