marquee跑马灯

<marquee>标签,它是成对出现的标签,首标签<marquee>和尾标签</marquee>之间的内容就是滚动内容。<marquee>标签的属性主要有behavior、bgcolor、direction、width、height、hspace、vspace、loop、scrollamount、scrolldelay等,它们都是可选的。 

behavior属性

behavior属性的参数值为alternate、scroll、slide中的一个,分别表示文字来回滚动、单方向循环滚动、只滚动一次,默认是scroll,需要注意的是:如果在<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>

bgcolor属性

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

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

direction属性

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

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

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

width和height属性

width和height属性的作用决定滚动文字在页面中的矩形范围大小。width属性用以规定矩形的宽度,height属性规定矩形的高度。这两个属性的参数值可以是数字或者百分数,数字表示矩形所占的(宽或高)像素点数,百分数表示矩形所占浏览器窗口的(宽或高)百分比。如下所示:

    <marquee width="300" height="30" bgcolor="red">我宽300像素,高30像素。</marquee>

 

hspace和vspace属性

这两个属性决定滚动矩形区域距周围的空白区域.

    <marquee width="300" height="30" vspace="10" hspace="10" bgcolor="red">我矩形边缘水平和垂直距周围各10像素。</marquee>

    <marquee width="300" height="30" vspace="50" hspace="50" bgcolor="red">我矩形边缘水平和垂直距周围各50像素。</marquee>

loop属性

loop属性决定滚动文字的滚动次数,默认是无限循环。参数值可以是任意的正整数,如果设置参数值为-1或infinite时将无限循环。如下所示:

    <marquee loop="2">我滚动2次。</marquee>

    <marquee loop="infinite">我无限循环滚动。</marquee>

    <marquee loop="-1">我无限循环滚动。</marquee>

scrollamount和scrolldelay属性

这两个属性决定文字滚动的速度(scrollamount)(默认是6)和延时(scrolldelay)(默认是0),参数值都是正整数。如下所示:

    <marquee scrollamount="100">我速度很快.</marquee>

    <marquee scrollamount="50">我慢了些。</marquee>

    <marquee scrolldelay="30">我小步前进。</marquee>

    <marquee scrolldelay="1000" scrollamount="100">我大步前进。</marquee>

 

onmouseover=this.stop() onmouseout=this.start() 表示当鼠标以上区域的时候滚动停止,当鼠标移开的时候又继续滚动。

<marquee width="500" behavior="alternate">
			<img src="img/logo.png"/>
			<img src="img/logo.png"/>
			<img src="img/logo.png"/>
			<img src="img/logo.png"/>
			<img src="img/logo.png"/>
			<img src="img/logo.png"/>
		</marquee>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章