HTML之marquee(文字滚动)详解
㈠簡(jiǎn)單介紹
⑴語(yǔ)法:<marquee></marquee>
以下是一個(gè)最簡(jiǎn)單的例子:
代碼如下:
<marquee><font size=+3 color=red>Hello, World</font></marquee>
⑵下面這兩個(gè)事件經(jīng)常用到:
onMouseOut="this.start()" :用來(lái)設(shè)置鼠標(biāo)移出該區(qū)域時(shí)繼續(xù)滾動(dòng)
onMouseOver="this.stop()":用來(lái)設(shè)置鼠標(biāo)移入該區(qū)域時(shí)停止?jié)L動(dòng)
代碼如下:
<marquee onMouseOut="this.start()" onMouseOver="this.stop()">
onMouseOut="this.start()" :用來(lái)設(shè)置鼠標(biāo)移出該區(qū)域時(shí)繼續(xù)滾動(dòng)
onMouseOver="this.stop()":用來(lái)設(shè)置鼠標(biāo)移入該區(qū)域時(shí)停止?jié)L動(dòng)</marquee>
⑶代碼如下:這是一個(gè)完整的例子
<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>
㈡該標(biāo)簽支持的屬性多達(dá)11個(gè):
⑴align設(shè)定<marquee>標(biāo)簽內(nèi)容的對(duì)齊方式
absbottom:絕對(duì)底部對(duì)齊(與g、p等字母的最下端對(duì)齊)
absmiddle:絕對(duì)中央對(duì)齊
baseline:底線對(duì)齊
bottom:底部對(duì)齊(默認(rèn))
left:左對(duì)齊
middle:中間對(duì)齊
right:右對(duì)齊
texttop:頂線對(duì)齊
top:頂部對(duì)齊
代碼如下:
<marquee align="absbottom">align="absbottom":絕對(duì)底部對(duì)齊(與g、p等字母的最下端對(duì)齊)。 </marquee> <marquee align="absmiddle">align="absmiddle": 絕對(duì)中央對(duì)齊。 </marquee> <marquee align="baseline">align="baseline": 底線對(duì)齊。 </marquee> <marquee align="bottom">align="bottom": 底部對(duì)齊(默認(rèn))。 </marquee> <marquee align="left">align="left": 左對(duì)齊。 </marquee> <marquee align="middle">align="middle": 中間對(duì)齊。 </marquee> <marquee align="right">align="right": 右對(duì)齊。 </marquee> <marquee align="texttop">align="texttop": 頂線對(duì)齊。 </marquee> <marquee align="top">align="top": 頂部對(duì)齊。 </marquee>
⑵behavior設(shè)定滾動(dòng)的方式:
alternate: 表示在兩端之間來(lái)回滾動(dòng)。
scroll: 表示由一端滾動(dòng)到另一端,會(huì)重復(fù)。
slide: 表示由一端滾動(dòng)到另一端,不會(huì)重復(fù)。
代碼如下:
<marquee behavior="alternate">alternate:表示在兩端之間來(lái)回滾動(dòng)。 </marquee> <marquee behavior="scroll">scroll:表示由一端滾動(dòng)到另一端,會(huì)重復(fù)。</marquee> <marquee behavior="slide">slide: 表示由一端滾動(dòng)到另一端,不會(huì)重復(fù)。</marquee>
⑶bgcolor設(shè)定活動(dòng)字幕的背景顏色
背景顏色可用RGB、16進(jìn)制值的格式或顏色名稱來(lái)設(shè)定。
代碼如下:
<marquee bgcolor="#006699">設(shè)定活動(dòng)字幕的背景顏色 bgcolor="#006699"</marquee> <marquee bgcolor="RGB(10%,50%,100%,)">設(shè)定活動(dòng)字幕的背景顏色 bgcolor="rgb(10%,50%,100%,)"</marquee> <marquee bgcolor="red">設(shè)定活動(dòng)字幕的背景顏色 bgcolor="red"</marquee>
⑷direction設(shè)定活動(dòng)字幕的滾動(dòng)方向
代碼如下:
<marquee direction="down">設(shè)定活動(dòng)字幕的滾動(dòng)方向direction="down":向下</marquee> <marquee direction="left">設(shè)定活動(dòng)字幕的滾動(dòng)方向direction="left":向左</marquee> <marquee direction="right">設(shè)定活動(dòng)字幕的滾動(dòng)方向direction="right":向右</marquee> <marquee direction="up">設(shè)定活動(dòng)字幕的滾動(dòng)方向direction="up":向上</marquee>
⑸height設(shè)定活動(dòng)字幕的高度
代碼如下:
<marquee height="500" direction="down" bgcolor="#CCCCCC">設(shè)定活動(dòng)字幕的高度height="500"</marquee>
⑹width 設(shè)定活動(dòng)字幕的寬度
代碼如下:
<marquee width="500" bgcolor="#CCCCCC">設(shè)定活動(dòng)字幕的寬度width="500"</marquee>
⑺hspace
設(shè)定活動(dòng)字幕里所在的位置距離父容器水平邊框的距離
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
設(shè)定活動(dòng)字幕里所在的位置距離父容器垂直邊框的距離
This controls the vertical(垂直) space around the display box.
代碼如下:
<marquee vspace="100" bgcolor="#CCCCCC">hspace="100"</marquee>
⑼loop設(shè)定滾動(dòng)的次數(shù)
當(dāng)loop=-1表示一直滾動(dòng)下去,默認(rèn)為-1
代碼如下:
<marquee loop="-1" bgcolor="#CCCCCC">我會(huì)不停地走。</marquee> <p> </p> <marquee loop="2" bgcolor="#CCCCCC">我只走兩次哦</marquee>
⑽scrollamount
設(shè)定活動(dòng)字幕的滾動(dòng)速度,單位pixels
代碼如下:
<marquee scrollamount="10" >scrollamount="10" </marquee> <marquee scrollamount="20" >scrollamount="20" </marquee> <marquee scrollamount="30" >scrollamount="30" </marquee>
⑾scrolldelay
設(shè)定活動(dòng)字幕滾動(dòng)兩次之間的延遲時(shí)間,單位millisecond(毫秒)
值大了會(huì)有一步一停頓的效果
代碼如下:
<marquee scrolldelay="10" >scrolldelay="10" </marquee> <marquee scrolldelay="100" > scrolldelay="100"</marquee> <marquee scrolldelay="1000">scrolldelay="1000" </marquee>
㈢其他方面(圖片,表格等)
<marquee> ... </marquee>
移動(dòng)屬性的設(shè)置 ,這種移動(dòng)不僅僅局限于文字,也可以應(yīng)用于圖片,表格等等
鼠標(biāo)屬性
onMouseOut=this.start() ........鼠標(biāo)移出狀態(tài)滾動(dòng)
onMouseOver=this.stop() .........鼠標(biāo)經(jīng)過(guò)時(shí)停止?jié)L動(dòng)
⑴方向
<direction=#> #=left, right ,up ,down <marquee direction=left>從右向左移!</marquee>
⑵方式
<bihavior=#> #=scroll, slide, alternate <marquee behavior=scroll>一圈一圈繞著走!</marquee> <marquee behavior=slide>只走一次就歇了!</marquee> <marquee behavior=alternate>來(lái)回走</marquee>
⑶循環(huán)
<loop=#> #=次數(shù);若未指定則循環(huán)不止(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>
⑸延時(shí)
<scrolldelay=#> <marquee scrolldelay=500 scrollamount=100>啦啦啦,我走一步,停一停!</marquee>
⑹外觀(Layout)設(shè)置
對(duì)齊方式(Align)
<align=#> #=top, middle, bottom <font size=6> <marquee align=# width=400>啦啦啦,我會(huì)移動(dòng)耶!</marquee> </font>
⑺底色
<bgcolor=#> #=rrggbb 16 進(jìn)制數(shù)碼,或者是下列預(yù)定義色彩: 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"title=文字內(nèi)容> 這是放文字或需要移動(dòng)的圖片(光標(biāo)放在這里時(shí)用INSERT命令就可以插入圖片)</marquee> </P>
⑽圖片滾動(dòng)
用<img src=相對(duì)路徑/文件名>的語(yǔ)句。并且要注意圖片名不要中文,要注意區(qū)分英文大小寫(xiě)。
⑾圖片做超鏈接
用<a href=>和</a>把<img>包圍,并且img必須設(shè)border=0,否則圖片會(huì)出現(xiàn)藍(lán)框。
<a href=http://www.sina.com.cn/><img src=../../j/01.jpg border=0></a>
其中a href=表示超鏈接,這是最常用的。練習(xí)的方法也很簡(jiǎn)單,就是平時(shí)用FP或DW做網(wǎng)頁(yè)的時(shí)候,要多查看源代碼。
⑿多張圖片排列滾動(dòng)
通常圖片和圖片之間用<br>(回行)或<p style=margin-top:9>(精確調(diào)整圖片間的距離)來(lái)鏈接。也可以把你的圖片先用表格排版,然后把這個(gè)表格的所有語(yǔ)句也加入到marquee中,讓
這個(gè)表格來(lái)滾動(dòng)。
代碼如:
<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>
總結(jié)
以上是生活随笔為你收集整理的HTML之marquee(文字滚动)详解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: IT认证一一看过来
- 下一篇: Transform 详细讲解