motion5

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<script>
    window.onload=function(){
        var aDiv=document.getElementsByTagName('div');
        for (let i = 0; i < aDiv.length; i++) {
            aDiv[i].timer=null;
            aDiv[i].onmouseover=function(){
                startMover(aDiv[i], 400,3)
            } 
            aDiv[i].onmouseout=function(){
                startMover(aDiv[i], 100,20)
            }  
        }
    }

    function startMover(acr,iTaget,sd){
        clearInterval(acr.timer);
        acr.timer=setInterval(function(){
            var spead=0;
            spead=(iTaget-acr.offsetWidth)/sd;
            spead=spead>0?Math.ceil(spead):Math.floor(spead);
            if (acr.offsetWidth==iTaget) {
                clearInterval(acr.timer);
            } else {
                acr.style.width=acr.offsetWidth+spead+'px';
            }
        },17)
    }
</script>
<style>
    div{
        width: 100px;
        height: 20px;
        background: rgb(0, 255, 136);
        margin: 10px;
    }
</style>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 亲爱的姑娘, 请你别再为自己找借口,想要成功没有任何理由可以阻挡你前行。我指的成功是家庭和谐,丈夫健康,女儿们健康...
    俞旭霞阅读 864评论 0 0
  • 2017出生人口是1723万。 我估计2018年出生人口会低于1700万。 一般来讲,有钱的人会多生孩子继承财产,...
    艾小墨阅读 3,192评论 1 1
  • 都说人是直线 从未知的世界出发 无限延伸 平行的 无论是否在同一平面 都只能永远遥遥相望 否则 总会有交点 或垂直...
    青梅3煮酒阅读 754评论 0 0
  • 我的发小高高,一直以来都是一个目标很明确的人,她从小就知道自己想要什么。当我还傻乎乎的只知道玩洋娃娃的时候,...
    以雅以蓝阅读 4,855评论 2 2