首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有空格的字幕

没有空格的字幕
EN

Stack Overflow用户
提问于 2010-07-08 03:09:14
回答 2查看 14.8K关注 0票数 0

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

代码语言:javascript
复制
<marquee scrollamount="2" scrolldelay="0" direction="up">
Element One<br/>
Element Two<br/>
...
Element Five Hundred and Thrty-Seven <!-- ;) -->
</marquee>

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

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

提前感谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-07-08 03:15:38

无意冒犯,我可以建议你最好不要使用字幕标签吗?

有关可用性问题的详细信息,请参阅此wikipedia page

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

票数 -1
EN

Stack Overflow用户

发布于 2014-01-07 21:12:01

代码语言:javascript
复制
<!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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3197994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档