zoukankan      html  css  js  c++  java
  • 两个文字向上滚动案列

    <html>
     <head>
        <style type="text/css">
            #demo{
                font-size:normal  14px;
                line-height: 7px;
                height:100px;
                width:200px;
                overflow:hidden;
                border:4px solid  #ddd;
                text-align:center;
            }
            #demo1 #demo2{
                height:80px;
                width:160px;
                float:center;
            }
        </style>
     </head>
     <body>
        <div id="demo">
            <div id="demo1">
                <p>你好啊</p>
                <p>欢迎下次光临</p>
                <p>要买就速度点</p>
                <p>别扣扣索索的</p>
                <p>我真的走了,你再不买就没得了</p>
            </div>
            <div id="demo2"></div>
        </div>
        <script type="text/javascript">
            var speed= 1;
            demo2.innerHTML = demo1.innerHTML; //设置一个空的div,把现有的div赋值给它
            function marquee(){
                if(demo2.offsetTop - demo.scrollTop <= 0){ //判断第一个div到底部了没有
                        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>
     </body>
    </html>
    <html>
    <h2>bianse</h2>
    <div id="scrollWrap"><div id="scrollMsg">我abcaef>abcaefgabcaefgabcaefgab<caefgabcaefgabcae<>fgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefgabcaefg</div></div>
    <style type="text/css">
    #scrollWrap { 
     width:100px;
     height: 200px; 
     overflow: hidden;
     border:2px solid red;
     word-wrap:break-word;
    } 
    h2 {color:red;background:#FFF;
    }
    h2:hover{color:green;background:purple;}
        </style>
        
        <script type="text/javascript"> 
    try{ 
     var isStoped = false; 
     var oScroll = document.getElementById("scrollWrap"); 
     with(oScroll){ 
     noWrap = true; 
     } 
     
     oScroll.onmouseover = new Function('isStoped = true'); 
     oScroll.onmouseout = new Function('isStoped = false'); 
     
     var preTop = 0; 
     var curTop = 0; 
     var stopTime = 0; 
     var oScrollMsg = document.getElementById("scrollMsg");
     
     oScroll.appendChild(oScrollMsg.cloneNode(true)); 
     init_srolltext(); 
    }catch(e) {} 
     
    function init_srolltext(){ 
     oScroll.scrollTop = 0; 
     setInterval('scrollUp()', 15); 
    } 
     
    function scrollUp(){ 
     if(isStoped) return; 
     curTop += 1; 
     if(curTop == 52) { 
     stopTime += 1; 
     curTop -= 1; 
     if(stopTime == 180) { 
     curTop = 0; 
     stopTime = 0; 
     } 
     }else{ 
     preTop = oScroll.scrollTop; 
     oScroll.scrollTop += 1; 
     if(preTop == oScroll.scrollTop){ 
     oScroll.scrollTop = 0; 
     oScroll.scrollTop += 1; 
     } 
     } 
    } 
    
    </html>
    
    
    
    
    
  • 相关阅读:
    安装插件 YouCompleteMe 成功却无法自动补全C++的解决办法
    Ubuntu 16.04 使用 vim_plug 安装插件 YouCompleteMe 报错“ycmd server SHUT DOWN”
    POJ #1062 昂贵的聘礼 有限制的最短路 枚举+dijkstra求最短路
    POJ #3259 Wormholes 判负环 SPFA
    POJ #1860 Currency Exchange 最短路径算法 Bellman-ford SPFA 判断负环
    spfa 算法模板 可求带负权边的最短路 判断负环
    POJ #1042 Gone Fishing 贪心
    路人甲
    Perface
    1. Perface
  • 原文地址:https://www.cnblogs.com/isuben/p/3843069.html
Copyright © 2011-2022 走看看