古詩詞大全網 - 字典詞典 - marquee如何讓文字上下來回滾動

marquee如何讓文字上下來回滾動

首先讓我們認識這個<marquee>標簽,它是成對出現的標簽,首標簽<marquee>和尾標簽</marquee>之間的內容就是滾動內容。<marquee>標簽的屬性主要有behavior、bgcolor、direction、width、height、hspace、vspace、loop、scrollamount、scrolldelay等,它們都是可選的。

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>

bgcolor屬性文字滾動範圍的背景顏色,參數值是16進制(形式:#AABBCC或#AA5566等)或預定義的顏色名字(如red、yellow、blue等)。如下所示:<marquee behavior=="slide" direction="left" bgcolor="red">我的背景色是紅色的</marquee>

direction屬性

文字滾動的方向,屬性的參數值有down、left、right、up***四個單壹可選值,分別代表滾動方向向下、向左、向右、向上。如下所示:

<marquee direction="right">我向右滾動</marquee>

<marquee direction="right">我向下滾動</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)和延時(scrolldelay),參數值都是正整數。如下所示:

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

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

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

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

最後說壹下align屬性,這個屬性決定滾動文字位於距形內邊框的上下左右位置。您也可以將<marquee>和</marquee>之間的內容替換為圖像或其它對象等