marquee标签可以用来插入一段滚动的文字,虽然现在大多数浏览器还支持该效果,但是该标签已经废弃,建议少使用。
最基础的滚动效果
自右向左进行滚动。
<marquee> Hello World! </marquee>
设置滚动方式:behavior
可选值有 scroll,slide 和 alternate。分别表示:循环滚动(从右往左,出线后回到右边)、只滚动一次和来回滚动(先从右往左,然后从左往右)。默认值为 scroll。
<marquee behavior="alternate"> Hello World! </marquee>
设置滚动背景颜色:bgcolor
通过颜色名称或十六进制值设置背景颜色(滚动区域的背景颜色)。
<marquee bgcolor="#000000"> Hello World! </marquee>
或
<marquee bgcolor="black"> Hello World! </marquee>
设置滚动方向:direction
可选值有 left, right, up和down,分别表示:向左、向右、向上和向下。如果未指定值,默认值为 left。
<marquee direction="right"> Hello World! </marquee>
设置滚动范围高度和宽度:height、width
height:以像素或百分比值设置高度。
width:以像素或百分比值设置宽度。
<marquee width="400px" height="200px"> Hello World! </marquee>
设置滚动的次数:loop
如果未指定值,默认值为 −1,表示 marquee 将连续滚动.
<marquee loop="3"> Hello World! </marquee>
设置每次滚动的长度:scrollamount
设置每次滚动时移动的长度(以像素为单位)。默认值为 6。
<marquee scrollamount="50px"> Hello World! </marquee>
或
<marquee scrollamount="50"> Hello World! </marquee>
设置每次滚动的时间间隔:scrolldelay
设置每次滚动时的时间间隔(以毫秒为单位)。默认值为 85。值越大,滚动越慢。
<marquee scrolldelay="200"> Hello World! </marquee>
除了上面的几个之外,还有:
truespeed
默认情况下,会忽略小于60的scrolldelay值。如果存在truespeed,那些值不会被忽略。
hspace
以像素或百分比值设置水平边距。
vspace
以像素或百分比值设置垂直边距。
在使用的时候可能有不支持的情况。