html文字向左移动

html文字向左移动,第1张

文字向左移动代码:

<marquee direction=left>需要移动的文字</marquee>

marquee:

<marquee>标签,是成对出现的标签,首标签<marquee>和尾标签</marquee>之间的内容就是滚动内容。

<marquee>标签的属性主要有behavior、bgcolor、direction、width、height、hspace、vspace、loop、scrollamount、scrolldelay等,它们都是可选的。

扩展资料:

1、behavior属性:

behavior属性的参数值为alternate、scroll、slide中的一个,分别表示文字来回滚动、单方向循环滚动、只滚动一次。

如果在<marquee>标签中同时出现了direction和behavior属性,那么scroll和slide的滚动方向将依照direction属性中参数的设置。

示例:

<marquee behavior="alternate">我来回滚动</marquee>

<marquee behavior="scroll">我单方向循环滚动</marquee>

<marquee behavior="scroll" direction="up" height="30">我改单方向向上循环滚动</marquee>

<marquee behavior="slide">我只滚动一次</marquee>

<marquee behavior="slide" direction="up">我改向上只滚动一次了</marquee>

2、bgcolor属性:

文字滚动范围的背景颜色,参数值是16进制(形式:#AABBCC或#AA5566等)或预定义的颜色名字(如red、yellow、blue等)。

示例:

<marquee behavior=="slide" direction="left" bgcolor="red">我的背景色是红色的</marquee> 

3、direction属性:

文字滚动的方向,属性的参数值有down、left、right、up共四个单一可选值,分别代表滚动方向向下、向左、向右、向上。

示例:

<marquee direction="right">我向右滚动</marquee>

<marquee direction="right">我向下滚动</marquee>

把代码保存为html格式,上传到网页空间看看是不是你想要的!

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset= gb2312">

<style type="text/css">

<!--

a { color: #00488C}

a:hover { color: #FF0000}

td { font-size: 12px color: #00488C}

-->

</style>

<script language=JAVAscript>

<!--

// ------ 定义全局变量

var theNewsNum

var theAddNum

var totalNum

var CurrentPosion=0

var theCurrentNews

var theCurrentLength

var theNewsText

var theTargetLink

var theCharacterTimeout

var theNewsTimeout

var theBrowserVersion

var theWidgetOne

var theWidgetTwo

var theSpaceFiller

var theLeadString

var theNewsState

function startTicker()

{

// ------ 设置初始数值

theCharacterTimeout = 50//字符间隔时间

theNewsTimeout = 2000//新闻间隔时间

theWidgetOne= "_"//新闻前面下标符1

theWidgetTwo= "-"//新闻前面下标符

theNewsState = 1

//theNewsNum= document.body.children.incoming.children.NewsNum.innerText//新闻总条数

//add by lin

theNewsNum= document.body.children.incoming.children.AllNews.children.length//新闻总条数

theAddNum= document.body.children.incoming.children.AddNews.children.length//补充条数

totalNum =theNewsNum+theAddNum

theCurrentNews = 0

theCurrentLength= 0

theLeadString = " "

theSpaceFiller = " "

runTheTicker()

}

// --- 基础函数

function runTheTicker()

{

if(theNewsState == 1)

{

if(CurrentPosion<theNewsNum){

setupNextNews()

}

else{

setupAddNews()

}

CurrentPosion++

if(CurrentPosion>=totalNum||CurrentPosion>=5) CurrentPosion=0 //最多条数不超过5条

}

if(theCurrentLength != theNewsText.length)

{

drawNews()

}

else

{

closeOutNews()

}

}

// --- 跳转下一条新闻

function setupNextNews()

{

theNewsState = 0

theCurrentNews = theCurrentNews % theNewsNum

theNewsText = document.body.children.incoming.children.AllNews.children[theCurrentNews].children.Summary.innerText

theTargetLink = document.body.children.incoming.children.AllNews.children[theCurrentNews].children.NewsLink.innerText

theCurrentLength = 0

document.all.hottext.href = theTargetLink

theCurrentNews++

}

function setupAddNews()

{

theNewsState = 0

theCurrentNews = theCurrentNews % theAddNum

theNewsText = document.body.children.incoming.children.AddNews.children[theCurrentNews].children.Summary.innerText

theTargetLink = document.body.children.incoming.children.AddNews.children[theCurrentNews].children.NewsLink.innerText

theCurrentLength = 0

document.all.hottext.href = theTargetLink

theCurrentNews++

}

// --- 滚动新闻

function drawNews()

{

var myWidget

if((theCurrentLength % 2) == 1)

{

myWidget = theWidgetOne

}

else

{

myWidget = theWidgetTwo

}

document.all.hottext.innerHTML = theLeadString + theNewsText.substring(0,theCurrentLength) + myWidget + theSpaceFiller

theCurrentLength++

setTimeout("runTheTicker()", theCharacterTimeout)

}

// --- 结束新闻循环

function closeOutNews()

{

document.all.hottext.innerHTML = theLeadString + theNewsText + theSpaceFiller

theNewsState = 1

setTimeout("runTheTicker()", theNewsTimeout)

}

window.onload=startTicker

//-->

</script>

</head>

<body>

<script type="text/javascript">

var vjAcc="860010-0120120000"

vjTrack()

</script>

<noscript>

<img src="http://cctv.doulog.com/a.gif?vjAcc=860010-0120120000" width="1" height="1" />

</noscript>

<table>

<tr><td>

<div id=visible>你的文字说明:<a href="" id=hottext target="_blank"></a></div>

</td></tr>

</table>

<div id=incoming style="DISPLAY: none">

<div id=AllNews>

<div id=1>

<div id=Summary>1.你想要的是不是这个样子的?(这是第一次) </div>

<div id=NewsLink></div>

</div>

<div id=2>

<div id=Summary>2.是不是这个样子的?(第二次提示了)</div>

<div id=NewsLink></div>

</div>

<div id=3>

<div id=Summary>3.如果是的话记得给分哦</div>

<div id=NewsLink></div>

</div>

<div id=4>

<div id=Summary>4.有空到我的站上看看啊,下一条就是我站的地址了 </div>

<div id=NewsLink></div>

</div>

<div id=5>

<div id=Summary>5.我站的地址是:http://aiyiya.cn </div>

<div id=NewsLink></div>

</div>

</div>

<div id=AddNews>

</div>

</div>

</body>

</html>

<!--remain-->


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6155170.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-16
下一篇 2023-03-16

发表评论

登录后才能评论

评论列表(0条)

保存