zoukankan      html  css  js  c++  java
  • Marquee 连续滚动

    在网上搜了一下几乎是同一个版本的连续滚动。并且有一些问题
    于是就自己写了一个
       <div id="Parent" style="cursor: hand; overflow: hidden;  800px; height:50px">
           
    <div id="Child_A" style="float:left;white-space:nowrap;"><a href="http://lookcode.net">lookcode</a> <a href="http://www.searoute.net">searoute</a>  </div>
        
    </div>
        
    <span id="spanMsg"></span>
        
    <script type="text/javascript">
        var Parent 
    = document.getElementById("Parent");
        var ChildA 
    = document.getElementById("Child_A");
        var parentWidth 
    = 800;
        var count
    =2
        ChildA.innerHTML 
    = ChildA.innerHTML + " " + ChildA.innerHTML;
        
    while (Parent.scrollWidth<=parentWidth)
        
    {    
            count 
    *=2;
            ChildA.innerHTML 
    = ChildA.innerHTML + " " + ChildA.innerHTML;
          
        }

        
    var speed
    =10;

    function Marquee()
    {
        
        
    if (ChildA.offsetWidth/count-Parent.scrollLeft<0)//NB Cacluate the optimal position
        {
            Parent.scrollLeft 
    -= ChildA.offsetWidth/count;
        }

        
    else
        
    {

            Parent.scrollLeft
    ++ 

        }

       
    }

    var MyMar
    =setInterval(Marquee,speed)
    Parent.onmouseover
    =function() {clearInterval(MyMar)}
    Parent.onmouseout
    =function() {MyMar=setInterval(Marquee,speed)}
        
    </script>

    ----write by lovebanyi 风云---
    主要的是思想是利用滚条动。所以我们需要两个element 并且我们代码一定得让它产生滚动条。就是对同一个文本进行多次复制 这样子就OK了
    第二就是计算出 重新开始的位置

    把overflow设成scroll 这样就可以看到滚动条的效果了。   对spanMsg进行赋值可以观察

    第四可以跟据代码做成你自己需要的向左向右向上向下。的代码
  • 相关阅读:
    Python socket 通信功能简介
    python2 && python3 的 input函数
    python 监听键盘输入
    std_msgs/String.msg
    python中string、json、bytes的转换
    python json与字典对象互相转换
    maven依赖关系中Scope的作用
    Maven项目下HttpServletRequest 或 HttpServletResponse需引用的依赖包
    Setup SS5 Socks Proxy
    Turn any Linux computer into SOCKS5 proxy in one command
  • 原文地址:https://www.cnblogs.com/lovebanyi/p/904458.html
Copyright © 2011-2022 走看看