Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无空间的帐篷_Javascript_Html_Marquee - Fatal编程技术网

Javascript 无空间的帐篷

Javascript 无空间的帐篷,javascript,html,marquee,Javascript,Html,Marquee,我有一个向上滚动的字幕 <marquee scrollamount="2" scrolldelay="0" direction="up"> Element One<br/> Element Two<br/> ... Element Five Hundred and Thrty-Seven <!-- ;) --> </marquee> 元素一 元素二 ... 第五十七单元 现在,我想要实现的是,当元素结束时,在最后一个元素不再显示之

我有一个向上滚动的字幕

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

元素一
元素二
... 第五十七单元
现在,我想要实现的是,当元素结束时,在最后一个元素不再显示之前没有空间,但是列表立即从头开始。我还希望字幕不要先向上滚动,让第一个元素一个接一个地出现,而是让第一个元素已经滚动到顶部,然后继续滚动。我提到的我需要实现的前一件事远比后一件重要。我不介意解决方案是否包括不制作字幕,而是一些带有滚动或类似内容的div。只是,请不要发布JQuery结果,而是纯JavaScript

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


提前谢谢

如果不想表现得粗鲁一点,我可以建议你不应该使用字幕标签吗

关于可用性问题的分解,请参见此

更好的方法是使用javascript逐步增强页面。这是一个。


.集装箱帐篷{
位置:相对位置;
宽度:100%;/*选框宽度*/
高度:200px;/*选框高度*/
溢出:隐藏;
背景色:白色;
填充:2px;
左侧填充:4px;
}
/***********************************************
*简易帐篷(2012年10月4日)
*作者:维克·菲利普斯http://www.vicsjavascripts.org.uk/
***********************************************/
var zxcMarquee={
初始化:函数(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=mde[1];
p、 style.overflow='hidden';
obj.style.position='absolute';
对象样式[mde[0]]='0px';
对象样式[mde[3]]=sz+'px';
克隆=对象克隆节点(真);
clone.style[mde[0]]=sz+'px';
clone.style[mde[2]='0px';
子对象(克隆);
o=此['zxc'+id]={
obj:obj,
mde:mde[0],
sz:sz
}
如果(类型(srt)=“编号”){
o、 dly=setTimeout(function(){zxcMarquee.scroll(id,typeof(ud)='number'?ud:-1);},srt);
}
否则{
此。滚动条(id,0)
}
},
滚动:功能(id、ud){
var oop=this,o=this['zxc'+id],p;
如果(o){
ud=类型(ud)=“编号”?ud:0;
清除超时(o.dly);
p=parseInt(o.obj.style[o.mde])+ud;

如果((ud>0&&p>0)|(ud
),神秘的无jQuery注释…有点过时,是吗?^^我实际上不想使用字幕标记。正如我所说,我实际上不想使用它。我所需要的是消除这个字幕示例没有提供的空白。这并不能回答问题。
<!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>