美文网首页
refreshAnimation

refreshAnimation

作者: Jadon7 | 来源:发表于2018-10-09 07:23 被阅读0次
    <!DOCTYPE html>
    <html>
    <head>
        <title>refreshAnimation</title>
    </head>
    <script type="text/javascript">
        window.onload=function()
        {
            var oDiv=document.getElementById('div1');
            var oUl=oDiv.getElementsByTagName('ul')[0];
            var aLi=oDiv.getElementsByTagName('li');
    
            oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;
            oUl.style.width=aLi[0].offsetWidth*aLi.length+'px';
    
            setInterval(function(){
                if (oUl.offsetLeft<-oUl.offsetWidth/2)
                {
                    oUl.style.left='0';
                }
                oUl.style.left=oUl.offsetLeft-3+'px';
            },3)
        }
    </script>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        #div1{
            overflow: hidden;
            width: 800px;
            height: 10px;
            background: #eee; 
            position: relative;
            margin: 300px auto;
        }
        #div1 ul{
            position: absolute;
            left: 0;
            top: 0;
        }
        #div1 ul li{
            width: 200px;
            height: 150px;
            float: left;
            list-style: none;
        }
    </style>
    <body>
        <div id="div1">
            <ul>
                <li><img src="img2/1.png"></li>
                <li><img src="img2/2.png"></li>
                <li><img src="img2/3.png"></li>
                <li><img src="img2/4.png"></li>
            </ul>
        </div>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:refreshAnimation

          本文链接:https://www.haomeiwen.com/subject/nknsaftx.html