HTML之marquee(文字滾動)詳解


㈠簡單介紹

⑴語法:<marquee></marquee>

以下是一個最簡單的例子:

代碼如下:

<marquee><font size=+3 color=red>Hello, World</font></marquee>

 

⑵下面這兩個事件經常用到:

onMouseOut="this.start()" :用來設置鼠標移出該區域時繼續滾動

onMouseOver="this.stop()":用來設置鼠標移入該區域時停止滾動

代碼如下:

<marquee onMouseOut="this.start()" onMouseOver="this.stop()">
onMouseOut="this.start()" :用來設置鼠標移出該區域時繼續滾動
onMouseOver="this.stop()":用來設置鼠標移入該區域時停止滾動</marquee>

 

⑶代碼如下:這是一個完整的例子

<marquee id="affiche" 
align
="left"
behavior
="scroll"
bgcolor
="#FF0000"
direction
="up"
height
="300"
width
="200"
hspace
="50"
vspace
="20"
loop
="-1"
scrollamount
="10"
scrolldelay
="100"
onMouseOut
="this.start()"
onMouseOver
="this.stop()">

</marquee>

 

 

㈡該標簽支持的屬性多達11個:

⑴align  設定<marquee>標簽內容的對齊方式

absbottom:絕對底部對齊(與g、p等字母的最下端對齊)

absmiddle:絕對中央對齊

baseline:底線對齊

bottom:底部對齊(默認)

left:左對齊

middle:中間對齊

right:右對齊

texttop:頂線對齊

top:頂部對齊

 

代碼如下:

<marquee align="absbottom">align="absbottom":絕對底部對齊(與g、p等字母的最下端對齊)。 </marquee>

<marquee align="absmiddle">align="absmiddle": 絕對中央對齊。 </marquee>

<marquee align="baseline">align="baseline": 底線對齊。 </marquee>

<marquee align="bottom">align="bottom": 底部對齊(默認)。 </marquee>

<marquee align="left">align="left": 左對齊。 </marquee>

<marquee align="middle">align="middle": 中間對齊。 </marquee>

<marquee align="right">align="right": 右對齊。 </marquee>

<marquee align="texttop">align="texttop": 頂線對齊。 </marquee>

<marquee align="top">align="top": 頂部對齊。 </marquee>

 

⑵behavior  設定滾動的方式:

alternate: 表示在兩端之間來回滾動。

scroll: 表示由一端滾動到另一端,會重復。

slide:      表示由一端滾動到另一端,不會重復。

 

代碼如下:

<marquee behavior="alternate">alternate:表示在兩端之間來回滾動。 </marquee>

<marquee behavior="scroll">scroll:表示由一端滾動到另一端,會重復。</marquee>

<marquee behavior="slide">slide:      表示由一端滾動到另一端,不會重復。</marquee>

 

⑶bgcolor設定活動字幕的背景顏色

背景顏色可用RGB、16進制值的格式或顏色名稱來設定。

代碼如下:

<marquee bgcolor="#006699">設定活動字幕的背景顏色 bgcolor="#006699"</marquee>

<marquee bgcolor="RGB(10%,50%,100%,)">設定活動字幕的背景顏色 bgcolor="rgb(10%,50%,100%,)"</marquee>

<marquee bgcolor="red">設定活動字幕的背景顏色 bgcolor="red"</marquee>

 

⑷direction  設定活動字幕的滾動方向

代碼如下:

<marquee direction="down">設定活動字幕的滾動方向direction="down":向下</marquee>

<marquee direction="left">設定活動字幕的滾動方向direction="left":向左</marquee>

<marquee direction="right">設定活動字幕的滾動方向direction="right":向右</marquee>

<marquee direction="up">設定活動字幕的滾動方向direction="up":向上</marquee>

 

⑸height  設定活動字幕的高度

代碼如下:

<marquee height="500" direction="down" bgcolor="#CCCCCC">設定活動字幕的高度height="500"</marquee>

 

⑹width  設定活動字幕的寬度

代碼如下:

<marquee width="500" bgcolor="#CCCCCC">設定活動字幕的寬度width="500"</marquee>

 

⑺hspace

設定活動字幕里所在的位置距離父容器水平邊框的距離

This controls the horizontal(水平)space around the display box.

代碼如下:     

<table width="500" border="1" align="center" cellpadding="0" cellspacing="0">

        <tr>

          <td><marquee hspace="100" bgcolor="#CCCCCC">hspace="100"</marquee></td>

        </tr>

      </table>

 

⑻vspace

設定活動字幕里所在的位置距離父容器垂直邊框的距離

This controls the vertical(垂直) space around the display box.

代碼如下:

<marquee vspace="100" bgcolor="#CCCCCC">hspace="100"</marquee>

 

⑼loop設定滾動的次數

當loop=-1表示一直滾動下去,默認為-1

代碼如下:

<marquee loop="-1" bgcolor="#CCCCCC">我會不停地走。</marquee>

<p>&nbsp;</p>

<marquee loop="2" bgcolor="#CCCCCC">我只走兩次哦</marquee>

 

⑽scrollamount

設定活動字幕的滾動速度,單位pixels

代碼如下:

<marquee scrollamount="10" >scrollamount="10" </marquee>

<marquee scrollamount="20" >scrollamount="20" </marquee>

<marquee scrollamount="30" >scrollamount="30" </marquee>

 

⑾scrolldelay

設定活動字幕滾動兩次之間的延遲時間,單位millisecond(毫秒)

值大了會有一步一停頓的效果

代碼如下:

<marquee scrolldelay="10" >scrolldelay="10" </marquee>

<marquee scrolldelay="100" > scrolldelay="100"</marquee>

<marquee scrolldelay="1000">scrolldelay="1000" </marquee>

 

 ㈢其他方面(圖片,表格等)

<marquee> ... </marquee>

移動屬性的設置 ,這種移動不僅僅局限於文字,也可以應用於圖片,表格等等

鼠標屬性

onMouseOut=this.start() ........鼠標移出狀態滾動

onMouseOver=this.stop() .........鼠標經過時停止滾動

⑴方向

<direction=#> #=left, right ,up ,down <marquee direction=left>從右向左移!</marquee>

 

⑵方式

<bihavior=#> #=scroll, slide, alternate <marquee behavior=scroll>一圈一圈繞着走!</marquee>

<marquee behavior=slide>只走一次就歇了!</marquee>

<marquee behavior=alternate>來回走</marquee>

 

⑶循環

<loop=#> #=次數;若未指定則循環不止(infinite) <marquee loop=3 width=50% behavior=scroll>只走 3 趟</marquee>

<marquee loop=3 width=50% behavior=slide>只走 3 趟</marquee>

<marquee loop=3 width=50% behavior=alternate>只走 3 趟!</marquee>

 

⑷速度

<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=#>

<marquee hspace=20 vspace=20 width=150 bgcolor=ffaaaa align=middle>面積!</marquee>

 

⑼</P>

<marquee id="iescroller" direction=left height=10 onMouseOut=start(); onMouseOver=stop(); scrollamount=2 scrolldelay=10 scrollleft="0" scrolltop="0" behavior="alternate" bgcolor="#999999" style="color: #ffffff; font-size: 14; font-family: '宋體', 'Arial','Helvetica', 'sans-serif'"title=文字內容> 這是放文字或需要移動的圖片(光標放在這里時用INSERT命令就可以插入圖片)</marquee> </P>

 

⑽圖片滾動

用<img src=相對路徑/文件名>的語句。並且要注意圖片名不要中文,要注意區分英文大小寫。

⑾圖片做超鏈接

用<a href=>和</a>把<img>包圍,並且img必須設border=0,否則圖片會出現藍框。

<a href=http://www.sina.com.cn/><img src=../../j/01.jpg border=0></a>

其中a href=表示超鏈接,這是最常用的。練習的方法也很簡單,就是平時用FP或DW做網頁的時候,要多查看源代碼。

⑿多張圖片排列滾動

通常圖片和圖片之間用<br>(回行)或<p style=margin-top:9>(精確調整圖片間的距離)來鏈接。也可以把你的圖片先用表格排版,然后把這個表格的所有語句也加入到marquee中,讓

這個表格來滾動。
代碼如:

<script>document.write('<marquee scrollAmount=2 width=340 height=160 direction=up onmouseover=stop() onmouseout=start()><a href=http://www.sina.com.cn/><img src=../../j/01.jpg border=0></a></marquee>')</script> 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。