代码之家  ›  专栏  ›  技术社区  ›  arik

无空间天棚

  •  0
  • arik  · 技术社区  · 14 年前

    我有一个向上滚动的字幕。

    <marquee scrollamount="2" scrolldelay="0" direction="up">
    Element One<br/>
    Element Two<br/>
    ...
    Element Five Hundred and Thrty-Seven <!-- ;) -->
    </marquee>
    

    现在,我想要实现的是,当元素结束时,在最后一个元素不再显示之前没有空间,但是列表立即从开始处开始。我也希望字幕不首先向上滚动,让第一个元素出现一个接一个,但开始有第一个元素已经滚动到顶部,然后只是继续滚动。我提到的前一件事要比后一件事重要得多。我不介意,如果解决方案涉及不使它成为一个天棚,但一些与滚动或诸如此类的div。只是,请不要发布JQuery结果,而是纯JavaScript。

    曾经有人问过这样一个问题,关于一个没有空白的字幕,但答案涉及到复制文本,尽管删除了第一个空白,但仍然留下了第二个空白。

    2 回复  |  直到 14 年前
        1
  •  -1
  •   Tom Wright    14 年前

    如果不想显得粗鲁的话,我可以建议你不应该使用字幕标签吗?

    看到这个了吗 wikipedia page 对于可用性问题的分解。

    example in jQuery .

        2
  •  0
  •   Dhanaji Vekhande    11 年前
    <!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" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    
    .container-marquee{
    position: relative;
    width:100%; /*marquee width */
    height: 200px; /*marquee height */
    overflow: hidden;
    background-color: white;
    padding: 2px;
    padding-left: 4px;
    }
    
    </style>
    
    <script type="text/javascript">
    
    /***********************************************
    * Simple Marquee (04-October-2012)
    * by Vic Phillips - http://www.vicsjavascripts.org.uk/
    ***********************************************/
    
    var zxcMarquee={
    
     init:function(o){
      var mde=o.Mode,mde=typeof(mde)=='string'&&mde.charAt(0).toUpperCase()=='H'?['left','offsetWidth','top','width']:['top','offsetHeight','left','height'],id=o.ID,srt=o.StartDelay,ud=o.StartDirection,p=document.getElementById(id),obj=p.getElementsByTagName('DIV')[0],sz=obj[mde[1]],clone;
      p.style.overflow='hidden';
      obj.style.position='absolute';
      obj.style[mde[0]]='0px';
      obj.style[mde[3]]=sz+'px';
      clone=obj.cloneNode(true);
      clone.style[mde[0]]=sz+'px';
      clone.style[mde[2]]='0px';
      obj.appendChild(clone);
      o=this['zxc'+id]={
       obj:obj,
       mde:mde[0],
       sz:sz
      }
      if (typeof(srt)=='number'){
       o.dly=setTimeout(function(){ zxcMarquee.scroll(id,typeof(ud)=='number'?ud:-1); },srt);
      }
      else {
       this.scroll(id,0)
      }
     },
    
     scroll:function(id,ud){
      var oop=this,o=this['zxc'+id],p;
      if (o){
       ud=typeof(ud)=='number'?ud:0;
       clearTimeout(o.dly);
       p=parseInt(o.obj.style[o.mde])+ud;
       if ((ud>0&&p>0)||(ud<0&&p<-o.sz)){
        p+=o.sz*(ud>0?-1:1);
       }
       o.obj.style[o.mde]=p+'px';
       o.dly=setTimeout(function(){ oop.scroll(id,ud); },50);
      }
     }
    }
    
    function init(){
    
     zxcMarquee.init({
      ID:'marquee1',     // the unique ID name of the parent DIV.                        (string)
      Mode:'Horizontal',   //(optional) the mode of execution, 'Vertical' or 'Horizontal'. (string, default = 'Vertical')
      StartDelay:2000,   //(optional) the auto start delay in milli seconds'.            (number, default = no auto start)
      StartDirection:-1  //(optional) the auto start scroll direction'.                  (number, default = -1)
     });
    
    
    }
    
    if (window.addEventListener)
     window.addEventListener("load", init, false)
    else if (window.attachEvent)
     window.attachEvent("onload", init)
    else if (document.getElementById)
     window.onload=init
    
    
    </script>
    
    </head>
    
    <body>
    <div id="marquee1" class="container-marquee" onmouseover="zxcMarquee.scroll('marquee1',0);" onmouseout="zxcMarquee.scroll('marquee1',-1);">
    <div style="position: absolute; width: 98%;">
    Excel in your CA Final exams! Seminars on Robomate CA at Belgaum on 12th Jan., at Mysore on 19th Jan. & Bangalore on 26th Jan. Register now by calling 1800267662!
    </div>
    </div>
    
    </body>
    
    </html>