当前位置:首页 > 代码 > 正文

文字无缝向左滚动代码(向右滚动代码)

admin 发布:2022-12-19 21:18 156


今天给各位分享文字无缝向左滚动代码的知识,其中也会对向右滚动代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

文字循环不间断向左滚动代码怎么写?

style type="text/css"

!--

body {

font-size: 9pt;

color: #000000;

}

a {

color: #0000FF;

text-decoration: none;

}

a:hover {

color: #FF0000;

text-decoration: underline;

}

--

/style

/head

body

div id="marquees" a href="#"链接一/a a href="#"链接二/a a href="#"链接三/a a href="#"链接四/a /div

div id="templayer" style="position:absolute;left:0;top:0;visibility:hidden"/div

script language="JavaScript"marqueesWidth=200;with(marquees){

style.height=0;

style.width=marqueesWidth;

style.overflowX="hidden";

style.overflowY="visible";

noWrap=true;

onmouseover=new Function("stopscroll=true");

onmouseout=new Function("stopscroll=false");

}

preLeft=0; currentLeft=0; stopscroll=false;function init(){

templayer.innerHTML="";

while(templayer.offsetWidthmarqueesWidth){

templayer.innerHTML+=marquees.innerHTML;

}

marquees.innerHTML+=templayer.innerHTML;

setInterval("scrollLeft()",100);

}init();function scrollLeft(){

if(stopscroll==true) return;

preLeft=marquees.scrollLeft;

marquees.scrollLeft+=1;

if(preLeft==marquees.scrollLeft){

marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;

}

}

/script

/body

网页文字左右滚动代码?

marquee

width=400

behavior=alternate

direction=left

scrollamount=20

border=1滚动文字/marquee

参数 用法介绍

width=400

跑马范围:宽为400

behavior=scroll,

slide,

alternate

跑马方式:循环绕行,只跑一次就停住,来回往复运动

direction=left,right 

跑马方向:从左向右,从右向左

scrollamount=20

 

跑马速度:数越大越快

无缝滚动的简单实现代码(推荐)

原理:

1.给ul一个绝对定位使其脱离文档流,left设置为0,把图片塞进ul里,编写一个“移动"函数,函数功能能够使ul的left以一个正速度向右跑动,

2.设置一个定时器,让"移动"函数每30(参数可变)毫秒执行一次

3.因为ul的长度会“跑”完,此时可以使ul的content也就是img增加一倍,

oUl.innerHTML

+=oUl.innerHTML;

4.此时因为ul的content增加,其width也会随着增大,根据实际项目展示图片数量可能改动或不确定性,

oUl.style.width

=

oLi.length*oLi[0].offsetWidth+'px';

5.往“移动”函数里增添代码。

5.1此时ul向右移动,判断当ul的offsetLeft0时,把ul向左拉“一半ul的宽度”,也就是使ul能够向右一直无限制移动

if(oUl.offsetLeft0){

oUl.style.left

=

-oUl.offsetWidth/2+'px';

}

5.2当ul向左移动,其offsetLeft跑了ul一半的宽度时,把整个ul拉回至初始的left:0;

if

(oUl.offsetLeft-oUl.offsetWidth/2)

{

oUl.style.left

=

0;

}

上代码:

html:

div

id="box"

ul

lia

href="#"img

src="1.jpg"

//a/li

lia

href="#"img

src="2.jpg"

//a/li

lia

href="#"img

src="3.jpg"

//a/li

lia

href="#"img

src="4.jpg"

//a/li

/ul

/div

css:

*

{margin:

0;padding:

0;}

#box{

width:

480px;

height:

110px;

border:

1px

red

solid;

margin:

100px

auto;overflow:

hidden;

position:

relative;

}

#box

ul{

position:

absolute;

left:

0;

top:

5px;}

#box

ul

li{list-style:

none;

float:

left;

width:

100px;

height:

100px;

padding-left:

16px;

}

#box

ul

li

img{width:

100px;

height:

100px;}

js:

script

window.onload

=

function(){

var

oDiv

=

document.getElementById('div1');

var

oUl

=

oDiv.getElementsByTagName('ul')[0];

var

oLi

=

oUl.getElementsByTagName('li');

var

aA

=

document.getElementsByTagName('a');

var

iSpeed

=

10;

//让ul开始就具有一个速度走动

oUl.innerHTML

+=oUl.innerHTML;

oUl.style.width

=

oLi.length*oLi[0].offsetWidth+'px';

aA[0].onclick

=

function(){

iSpeed

=

-10;

};

aA[1].onclick

=

function(){

iSpeed

=

10;

};

function

fnMove(){

if

(oUl.offsetLeft-oUl.offsetWidth/2)

{

//负数是因为ul的left是负数

oUl.style.left

=

0;

}

else

if(oUl.offsetLeft0){

oUl.style.left

=

-oUl.offsetWidth/2+'px';

}

oUl.style.left

=

oUl.offsetLeft+iSpeed+'px';

//整个ul向右移动

};

var

timer

=

null;

clearInterval(timer);

timer

=

setInterval(fnMove,30);

oUl.onmouseover

=

function(){

clearInterval(timer);

};

oUl.onmouseout

=

function(){

timer

=

setInterval(fnMove,30);

//当鼠标移开的时候执行这个定时器

};

};

/script

如有错误,欢迎指正。

以上这篇无缝滚动的简单实现代码(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

麻烦大家了,我想问下。文字向左和向右滚动代码是什么呢。。谢谢大家如题 谢谢了

会移动的文字(Marquee) -------------------------------------------------------------------------------- 基本语法 marquee ... /marquee marquee啦啦啦,我会移动耶!/marquee 啦啦啦,我会移动耶! 文字移动属性的设置 方向direction=# #=left, right marquee direction=left啦啦啦,我从右向左移!/marquee P marquee direction=right啦啦啦,我从左向右移!/marquee 啦啦啦,我从右向左移! 啦啦啦,我从左向右移! 方式bihavior=# #=scroll, slide, alternate marquee behavior=scroll啦啦啦,我一圈一圈绕着走!/marquee P marquee behavior=slide啦啦啦,我只走一次就歇了!/marquee P marquee behavior=alternate啦啦啦,我来回走耶!/marquee 啦啦啦,我一圈一圈绕着走! 啦啦啦,我只走一次就歇了! 啦啦啦,我来回走耶! 循环loop=# #=次数;若未指定则循环不止(infinite) marquee loop=3 width=50% behavior=scroll啦啦啦,我只走 3 趟哟!/marquee P marquee loop=3 width=50% behavior=slide啦啦啦,我只走 3 趟哟!/marquee P marquee loop=3 width=50% behavior=alternate啦啦啦,我只走 3 趟哟!/marquee 啦啦啦,我只走 3 趟哟! 啦啦啦,我只走 3 趟哟! 啦啦啦,我只走 3 趟哟! 速度scrollamount=# marquee scrollamount=20啦啦啦,我走得好快哟!/marquee 啦啦啦,我走得好快哟! 延时scrolldelay=# marquee scrolldelay=500 scrollamount=100啦啦啦,我走一步,停一停!/marquee 啦啦啦,我走一步,停一停! 外观(Layout)设置 对齐方式(Align) align=# #=top, middle, bottom font size=6 marquee align=# width=400啦啦啦,我会移动耶!/marquee /font 对齐上沿、中间、下沿。 啦啦啦,我会移动耶!对齐上沿。 啦啦啦,我会移动耶!对齐中间。 啦啦啦,我会移动耶!对齐下沿。 底色bgcolor=# #=rrggbb 16 进制数码,或者是下列预定义色彩: Black, Olive, Teal, Red, Blue, Maroon, Navy, Gray, Lime, Fuchsia, White, Green, Purple, Silver, Yellow, Aqua marquee bgcolor=aaaaee啦啦啦,我会移动耶!/marquee 啦啦啦,我会移动耶! 面积height=# width=# marquee height=40 width=50% bgcolor=aaeeaa 啦啦啦,我会移动耶! /marquee 啦啦啦,我会移动耶! 空白(Margins)hspace=# vspace=# ********************************************br 嗨, marquee hspace=20 vspace=20 width=150 bgcolor=ffaaaa align=middle啦啦啦,我会移动耶!/marquee 大家好!br 把这些复制到网页里看一下就知道了

javascript 模拟Marquee文字向左均匀滚动代码

可以实现匀速、无缝、加链接以及其它的修饰效果,本代码就是实现了这一功能,让文字从右至右平滑滚动,滚动宽度、高度、速度均可以设定。

Js文字向左运动

var

marqueewidth=350

var

marqueeheight=22

var

speed=5

var

marqueecontents='欢迎光临脚本之家

网页特效栏目,精品特效全收罗!'

if

(document.all)

document.write(''+marqueecontents+'')

function

regenerate(){

window.location.reload()

}

function

regenerate2(){

if

(document.layers){

setTimeout("window.onresize=regenerate",450)

intializemarquee()

}

}

function

intializemarquee(){

document.cmarquee01.document.cmarquee02.document.write(''+marqueecontents+'')

document.cmarquee01.document.cmarquee02.document.close()

thelength=document.cmarquee01.document.cmarquee02.document.width

scrollit()

}

function

scrollit(){

if

(document.cmarquee01.document.cmarquee02.left=thelength*(-1)){

document.cmarquee01.document.cmarquee02.left-=speed

setTimeout("scrollit()",100)

}

else{

document.cmarquee01.document.cmarquee02.left=marqueewidth

scrollit()

}

}

window.onload=regenerate2

[Ctrl+A

全选

注:如需引入外部Js需刷新才能执行]

文字无缝向左滚动代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于向右滚动代码、文字无缝向左滚动代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/24602.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载