• Javascript做图片无缝平滑滚动


    因需要,google得到。作者不详。多谢。我这里略作修改。只是改变了ID。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>向左无缝滚动</title> 
    <style type="text/css"> 
    body,html,div,a{ margin:0 auto; padding:0} 
    #scroll_top {background: #FFF; overflow:hidden; border: 1px dashed #CCC; width: 98%; } 
    #scroll_top img {border: 3px solid #F2F2F2; } 
    #scroll_main {float: left; width: 800%; } 
    #scroll1 {float: left; } 
    #scrol2 { float: left; margin-left:7px; } 
    </style> 
    <script type="text/javascript"> 
    window.onload = function(){ 
    var speed=50;var tab=document.getElementById("scroll_top"); 
    var tab1=document.getElementById("scroll1"); 
    var tab2=document.getElementById("scrol2"); 
    tab2.innerHTML=tab1.innerHTML; 
    function Marquee(){ 
    if(tab2.offsetWidth-tab.scrollLeft<=0) 
    tab.scrollLeft-=tab1.offsetWidth 
    else{ 
    tab.scrollLeft++; 
    } 
    } 
    var MyMar=setInterval(Marquee,speed); 
    tab.onmouseover=function() {clearInterval(MyMar)}; 
    tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; 
    } 
    </script> 
    </head> 
    <body> 
     
    <div id="scroll_top"> 
    <div id="scroll_main"> 
    <div id="scroll1"> 
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    <img src="http://www.google.com/images/errors/robot.png" alt="404" />
    </div> 
    <div id="scrol2" ></div> 
    </div> 
    </div> 
    </body> 
    </html>

    特来收藏。

    Live Like You're Dying And Never Stop Tying
  • 相关阅读:
    Altium Designer 16 问题解决
    IAR FOR AVR 仿真过程中出现全局变量值不断随意变化的问题
    linux '--stdin'错误 -批量修改密码
    EmWin 字体相关函数
    EmWin 文本显示函数
    Win10下 usart驱动PL2303无法安装的问题
    EmWin 接触---基础函数
    Linux 下 Samba 服务器搭建
    MPLAB X IDE V4.15 创建工程,编译,问题处理
    EF Core MVC
  • 原文地址:https://www.cnblogs.com/dying/p/3213862.html
Copyright © 2020-2023  润新知