html循环滚动文字代码(html循环标签)
大家好,今天来为大家分享html循环滚动文字代码的一些知识点,和html循环标签的问题解析,大家要是都明白,那么可以忽略,如果不太清楚的话可以看看本篇文章,相信很大概率可以解决您的问题,接下来我们就一起来看看吧!
html滚动文字代码是什么
<marquee direction=up behavior=scroll loop=3 scrollamount=1 scrolldelay=10 align=top bgcolor=#ffffff height=300 width=30% hspace=20 vspace=10 onmouseover=this.stop() onmouseout=this.start()>此处输入滚动内容</marquee>
◎ direction表示滚动的方向,值可以是left,right,up,down,默认为left
◎ behavior表示滚动的方式,值可以是scroll(连续滚动)slide(滑动一次)alternate(往返滚动)
◎ loop表示循环的次数,值是正整数,默认为无限循环
◎ scrollamount表示运动速度,值是正整数,默认为6
◎ scrolldelay表示停顿时间,值是正整数,默认为0,单位似乎是毫秒
◎ align表示元素的垂直对齐方式,值可以是top,middle,bottom,默认为middle
◎ bgcolor表示运动区域的背景色,值是16进制的RGB颜色,默认为白色
◎ height、width表示运动区域的高度和宽度,值是正整数(单位是像素)或百分数,默认width=100% height为标签内元素的高度
◎ hspace、vspace表示元素到区域边界的水平距离和垂直距离,值是正整数,单位是像素。
◎ onmouseover=this.stop() onmouseout=this.start()表示当鼠标以上区域的时候滚动停止,当鼠标移开的时候又继续滚动。
求文字向上无限循环滚动代码,无缝隙循环,要HTML的。
<!DOCTYPE>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>向上下左右不间断无缝滚动效果(兼容火狐和IE)</title>
</head>
<body>
<divid="colee"style="overflow:hidden;height:253px;width:410px;">
<divid="colee1">
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
<p>此处放文字。。。。。。。。。</p>
</div>
<divid="colee2"></div>
</div>
<script>
varspeed=30;
varcolee2=document.getElementById("colee2");
varcolee1=document.getElementById("colee1");
varcolee=document.getElementById("colee");
colee2.innerHTML=colee1.innerHTML;//克隆colee1为colee2
functionMarquee1(){
//当滚动至colee1与colee2交界时
if(colee2.offsetTop-colee.scrollTop<=0){
colee.scrollTop-=colee1.offsetHeight;//colee跳到最顶端
}else{
colee.scrollTop++
}
}
varMyMar1=setInterval(Marquee1,speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover=function(){clearInterval(MyMar1)}
//鼠标移开时重设定时器
colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}
</script>
<!--向上滚动代码结束-->
<br>
<!--下面是向下滚动代码-->
<divid="colee_bottom"style="overflow:hidden;height:253px;width:410px;">
<divid="colee_bottom1">
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
<p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p>
</div>
<divid="colee_bottom2"></div>
</div>
<script>
varspeed=30
varcolee_bottom2=document.getElementById("colee_bottom2");
varcolee_bottom1=document.getElementById("colee_bottom1");
varcolee_bottom=document.getElementById("colee_bottom");
colee_bottom2.innerHTML=colee_bottom1.innerHTML
colee_bottom.scrollTop=colee_bottom.scrollHeight
functionMarquee2(){
if(colee_bottom1.offsetTop-colee_bottom.scrollTop>=0)
colee_bottom.scrollTop+=colee_bottom2.offsetHeight
else{
colee_bottom.scrollTop--
}
}
varMyMar2=setInterval(Marquee2,speed)
colee_bottom.onmouseover=function(){clearInterval(MyMar2)}
colee_bottom.onmouseout=function(){MyMar2=setInterval(Marquee2,speed)}
</script>
<!--向下滚动代码结束-->
<br>
<!--下面是向左滚动代码-->
<divid="colee_left"style="overflow:hidden;width:500px;">
<tablecellpadding="0"cellspacing="0"border="0">
<tr><tdid="colee_left1"valign="top"align="center">
<tablecellpadding="2"cellspacing="0"border="0">
<tralign="center">
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
</tr>
</table>
</td>
<tdid="colee_left2"valign="top"></td>
</tr>
</table>
</div>
<script>
//使用div时,请保证colee_left2与colee_left1是在同一行上.
varspeed=30//速度数值越大速度越慢
varcolee_left2=document.getElementById("colee_left2");
varcolee_left1=document.getElementById("colee_left1");
varcolee_left=document.getElementById("colee_left");
colee_left2.innerHTML=colee_left1.innerHTML
functionMarquee3(){
if(colee_left2.offsetWidth-colee_left.scrollLeft<=0)//offsetWidth是对象的可见宽度
colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth是对象的实际内容的宽,不包边线宽度
else{
colee_left.scrollLeft++
}
}
varMyMar3=setInterval(Marquee3,speed)
colee_left.onmouseover=function(){clearInterval(MyMar3)}
colee_left.onmouseout=function(){MyMar3=setInterval(Marquee3,speed)}
</script>
<!--向左滚动代码结束-->
<br>
<!--下面是向右滚动代码-->
<divid="colee_right"style="overflow:hidden;width:500px;">
<tablecellpadding="0"cellspacing="0"border="0">
<tr><tdid="colee_right1"valign="top"align="center">
<tablecellpadding="2"cellspacing="0"border="0">
<tralign="center">
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
<td><p><imgsrc="/jscss/demoimg/200907/bg3.jpg"></p></td>
</tr>
</table>
</td>
<tdid="colee_right2"valign="top"></td>
</tr>
</table>
</div>
<script>
varspeed=30//速度数值越大速度越慢
varcolee_right2=document.getElementById("colee_right2");
varcolee_right1=document.getElementById("colee_right1");
varcolee_right=document.getElementById("colee_right");
colee_right2.innerHTML=colee_right1.innerHTML
functionMarquee4(){
if(colee_right.scrollLeft<=0)
colee_right.scrollLeft+=colee_right2.offsetWidth
else{
colee_right.scrollLeft--
}
}
varMyMar4=setInterval(Marquee4,speed)
colee_right.onmouseover=function(){clearInterval(MyMar4)}
colee_right.onmouseout=function(){MyMar4=setInterval(Marquee4,speed)}
</script>
<!--向右滚动代码结束-->
</body>
</html>
实现移动文字效果的HTML代码
用<marquee>标记你要移动的文字段就可以了。
你可以设置<marquee>属性来控制一些表现形式:
1.direction——滚动的方向,值可以是left,right,up,down 2.behavior——滚动的方式,值可以是scroll(连续滚动)slide(滑动一次)alternate(来回滚动)
3.loop——循环的次数,值是正整数,默认为无限循环
4.scrollamount——运动速度,值是正整数,默认为6
5.scrolldelay——停顿时间,值是正整数,默认为0,单位是毫秒
6.valign——元素的垂直对齐方式,值可以是top,middle,bottom,默认为middle
7.height、width——运动区域的高度和宽度,值是正整数(单位是像素)或百分数,默认width=100% height为标签内元素的高度
9hspace、vspace——元素到区域边界的水平距离和垂直距离,值是正整数,单位是像素。
8.onmouseover=this.stop() onmouseout=this.start()表示当鼠标以上区域的时候滚动停止,当鼠标移开的时候又继续滚动
关于本次html循环滚动文字代码和html循环标签的问题分享到这里就结束了,如果解决了您的问题,我们非常高兴。