跑马灯 (停顿);上下

作者: 多多VS串串 | 来源:发表于2017-12-20 18:06 被阅读0次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style> 
            #Marquee{ height:60px; overflow:hidden;} 
            #Marquee div{ border:1px solid #DDD3FE; background:#EEECF4; height:58px;} 
        </style>     
    </head>
    <body>
        <div id="Marquee"> 
            <div style="width: 160px; height: 58px">111111</div> 
            <div style="width: 160px; height: 58px">22222</div> 
            <div style="width: 160px; height: 58px">3333333</div> 
        </div>
        <script> 
            var Mar = document.getElementById("Marquee"); 
            var child_div=Mar.getElementsByTagName("div") 
            var picH = 60;//移动高度 
            var scrollstep=3;//移动步幅,越大越快 
            var scrolltime=20;//移动频度(毫秒)越大越慢 
            var stoptime=3000;//间断时间(毫秒) 
            var tmpH = 0; 
            Mar.innerHTML += Mar.innerHTML; 
            function start(){ 
                if(tmpH < picH){ 
                    tmpH += scrollstep; 
                    if(tmpH > picH )tmpH = picH ; 
                    Mar.scrollTop = tmpH; 
                    setTimeout(start,scrolltime); 
                }else{ 
                    tmpH = 0; 
                    Mar.appendChild(child_div[0]); 
                    Mar.scrollTop = 0; 
                    setTimeout(start,stoptime); 
                } 
            } 
            onload=function(){setTimeout(start,stoptime)}; 
        </script>
    </body>
    </html>
    

    相关文章

      网友评论

        本文标题:跑马灯 (停顿);上下

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