怎么实现marquee标签的向上无缝滚动? 5
<li>1 <a href="#" title="信息公开工作">挺酷的VB打字效果,加载外部TXT文本</a></li>
<li>2 <a href="#" title="信息公开工作">国务院办公厅转发监察部等部门 </a></li>
而我滚动的文字部分全部来自一个变量a,文字的格式也是在a中设置的,请问该怎么解决这个问题? 展开
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<style>
#marquee p{height:30px;line-height: 30px;margin:0}
</style>
<div style="height:30px;overflow:hidden;">
<div id='marquee'>
<p>第1段</p>
<p>第2段</p>
<p>第3段</p>
<p>第4段</p>
<p>第5段</p>
</div>
</div>
<script>
(function(){
var marquee = document.getElementById('marquee');
var offset=0;
var scrollheight =marquee.offsetHeight;
var firstNode = marquee.children[0].cloneNode(true);
marquee.appendChild(firstNode);//还有这里
setInterval(function(){
if(offset == scrollheight){
offset = 0;
}
marquee.style.marginTop = "-"+offset+"px";
offset += 1;
},50);
})();
</script>
</body></html>
<div id="demo" style="overflow:hidden;height:168px;width:300px;">
<div id="demo1">
<!--此处放要显示的内容-->
</div>
<div id="demo2"></div>
</div>
<script language="javascript">
var speed=30;
var demo2=document.getElementByIdx_x("demo2");
var demo1=document.getElementByIdx_x("demo1");
var demo=document.getElementByIdx_x("demo");
demo2.innerHTML=demo1.innerHTML;
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0){
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>
—— 【仙】墨纸
先写个案例
<marquee style="width: 100%;" scrollamount="2" direction="up" behaviour="Scroll">这是案例这是案例这是案例这是案例这是案例这是案例这是案例</marquee>
在说说direction属性
direction="left"
向左(默认值)
direction="right"
向右
direction="down"
向下
direction="up"
向上
代码:
<marquee direction="up">我向上滚动</marquee>