zoukankan      html  css  js  c++  java
  • JS无缝文字滚动(兼容各大浏览器)

    <style>
    *{margin:0px;padding:0px;border:0px;}
    body{font-size:12px}
    #demo1{
    height:auto;
    text-align:left;
    }
    #demo2{
    height:auto;
    text-align:left;
    }
    #demo1 li{
    list-style-type:none;
    height:22px;
    background:url() no-repeat left center;
    text-align:left;
    text-indent:15px;
    }
    #demo2 li{
    list-style-type:none;
    height:22px;
    background:url() no-repeat left center;
    text-align:left;
    text-indent:15px;
    }
    </style>
    </head>
    <body>
    <div id="demo" style="overflow:hidden;height:50px;280px;">
    <ul id="demo1">
    <li><a href="#" target="_blank">1</a></li>
    <li><a href="#" target="_blank">2</a></li>
    <li><a href="#" target="_blank">3</a></li>
    <li><a href="#" target="_blank">4</a></li>
    <li><a href="#" target="_blank">5</a></li>
    <li><a href="#" target="_blank">6</a></li>
    <li><a href="#" target="_blank">7</a></li>
    </ul>
    <div id="demo2"></div>
    </div>
    <script>
    var speed=100
    var demo=document.getElementById("demo");
    var demo2=document.getElementById("demo2");
    var demo1=document.getElementById("demo1");
    demo2.innerHTML=demo1.innerHTML
    function Marquee(){
    if(demo2.offsetTop-demo.scrollTop<=0)
    demo.scrollTop-=demo1.offsetHeight
    else{
    demo.scrollTop++
    }
    }
    var MyMar=setInterval(Marquee,speed)
    demo.onmouseover=function() {clearInterval(MyMar)}
    demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
    </script>

  • 相关阅读:
    npm常用命令
    关于事件委托和时间冒泡(以及apply和call的事项)
    js 杂记
    angular中关于ng-repeat的性能问题
    关于日期的一些东西
    杂记
    angular中关于自定义指令——repeat渲染完成后执行动作
    angular中事件戳转日期的格式
    ES6-promise
    angular中ng-class的一些用法
  • 原文地址:https://www.cnblogs.com/roves/p/4923325.html
Copyright © 2011-2022 走看看