• 新闻滚动


    HMTL

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <style>
             *{
                 padding:0;
                margin:0;
             }
             li{ 
                 vertical-align:bottom;  
                list-style-type:none;
             }
             .hotNews {
                 width:100%;
                 background: #000;
                 position: relative;
                 overflow:hidden;
            }
            .hotNews  ul{
                height:24px;
                overflow:hidden;
                margin-left:10px;
            }
            .hotNews ul li{
                height:24px;
                line-height:24px;
                color:#fff;
                font-size: 12px;
            }
            .notice_close{
                 position: absolute;
                 right:15px;
                 top:50%;
                 width:20px;
                 margin-top:-10px;
                 z-index: 1;
             }
            </style>
        </head>
        <body>
            <div class="hotNews" id="hotNews">
                <ul id="hotNewsUl">
                     <li>任志强:房价不高,胸罩比房子还暴利</li>
                     <li>木子美:约炮不是卖淫也不是性骚扰</li>
                     <li>里宁:现在的男人几乎没有不出轨的</li>
                     <li>李剑芒:毛时代农民进城隔夜不归是罪</li>
                     <li>冯学荣:北洋时期媒体可随意讽刺政府</li>
                </ul>
                <img  class="notice_close" src="regCloseIndex.png" />
            </div>
        </body>
    </html>

    JS插件

    <script type="text/javascript">
    function scollNew(element){
        if(arguments.length>1){
           for(var i=0,length=arguments.length,elements=[];i<length;i++){
               elements.push(scollNew(arguments[i]));
           };
          return elements;
        };
        if(typeof element=="string"){
          return document.getElementById(element);
        }else{
          return element;
        };
    }
    var Class={
        create:function(){
            return function(){
                this.initialize.apply(this,arguments);
            }
        }
    }
    Function.prototype.bind=function(object){
        var method=this;
        return function(){
             method.apply(object,arguments);
        }
    }
    var Scroll=Class.create();
    Scroll.prototype={
         initialize:function(element,height){
          this.element=scollNew(element);
          this.element.innerHTML+=this.element.innerHTML;
          this.height=height;
          this.maxHeight=this.element.scrollHeight/2;
          this.counter=0;
          this.scroll();
          this.timer="";
          this.element.onmouseover=this.stop.bind(this);
          this.element.onmouseout=function(){this.timer=setTimeout(this.scroll.bind(this),1000);}.bind(this);
          var dom=document.getElementById(element);
          var domLi=dom.getElementsByTagName("li");
              for(var i=0;i<domLi.length;i++){
                  domLi[i].style.height=height+"px";
                  domLi[i].style.lineHeight=height+"px";
              }
              dom.style.height=height+"px";
         },
         scroll:function(){
              if(this.element.scrollTop<this.maxHeight){
                   this.element.scrollTop++;
                   this.counter++;
              }else{
                   this.element.scrollTop=0;
                   this.counter=0;
              }
              if(this.counter<this.height){
                    this.timer=setTimeout(this.scroll.bind(this),20);
              }else{
                   this.counter=0;
                   this.timer=setTimeout(this.scroll.bind(this),3000);
              }
         },
         stop:function(){
            clearTimeout(this.timer);
         }
    }
    var myscroll=new Scroll("hotNewsUl",40);
    </script>
  • 相关阅读:
    C#跨窗体操作
    搞IT的不如去养鸡养猪了
    C# 委托实例(跨窗体操作控件)
    FastReport 自定义页长
    SQL 根据一个表更新另一个表的内容
    Delphi中用ADOQuery实现主从表的例子(转)
    旅行的意义
    嘉州影院的网址
    纯粹的人
    Delphi中流的使用:压缩与解压缩(TCompressionStream、TDecompressionStream)
  • 原文地址:https://www.cnblogs.com/binmengxue/p/6381374.html
Copyright © 2020-2023  润新知