• 慕课网多物体运动源代码


    慕课网多物体运动源代码
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>多物体运动</title>
    <style>
    ul,li{
    list-style: none;
    }
    ul li{
    200px;
    height:100px;
    background:yellow;
    margin-bottom: 20px;
    }
    </style>
    <script>
    window.onload=function(){
    var ali=document.getElementsByTagName('li');
    for(var i=0;i<ali.length;i++){
    ali[i].timer=null
    ali[i].onmouseover=function(){
    startMove(this,400);
    }
    ali[i].onmouseout=function(){
    startMove(this,200);
    }
    }
    }
    // var timer=null;
    function startMove(obj,iTarget){
    clearInterval(obj.timer);
    obj.timer=setInterval(function(){
    var speed=(iTarget-obj.offsetWidth)/8;
    speed=speed>0?Math.ceil(speed):Math.floor(speed);
    if(obj.offsetWidth==iTarget){
    clearInterval(obj.timer);
    }else{
    obj.style.width=obj.offsetWidth+speed+'px';
    }
    },30)
    }
    </script>
    </head>
    <body>
    <ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    </ul>
    </body>
    </html>
    慕课网视频网址http://www.imooc.com/video/3048
  • 相关阅读:
    HTTPS
    RPC
    2017.4.19上午
    2017.4.18下午
    2017.4.18上午
    2017.4.17下午
    2017.4.17上午
    2017.4.14下午
    2017.4.14上午
    2017.4.13下午
  • 原文地址:https://www.cnblogs.com/milkytea/p/6986152.html
Copyright © 2020-2023  润新知