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>

 

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