1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > html之marquee滚动标签详解——实现无缝滚动跑马灯效果

html之marquee滚动标签详解——实现无缝滚动跑马灯效果

时间:2020-11-02 22:53:11

相关推荐

html之marquee滚动标签详解——实现无缝滚动跑马灯效果

html之marquee滚动标签详解——实现无缝滚动跑马灯效果

Vue3.0 无缝滚动组件:vue3-seamless-scroll

vue3.0滚动的table组件:vue3-scroll-table ——Demo: https://namewjp.github.io/vue3-scroll-table/

Marquee标记用于在可用浏览区域中滚动文本。

容器标签语法:

<marquee></marquee>

1、示例

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

事件经常用到:

onMouseOut=“this.start()” :用来设置鼠标移出该区域时继续滚动

onMouseOver=“this.stop()”:用来设置鼠标移入该区域时停止滚动

示例

<marquee 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>

2、标签支持的属性

多达11个:

2.1、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>

2.2、behavior:设定滚动的方式

alternate: 表示在两端之间来回滚动。

scroll: 表示由一端滚动到另一端,会重复。

slide: 表示由一端滚动到另一端,不会重复。

示例

<marquee behavior="alternate">alternate:表示在两端之间来回滚动。 </marquee><marquee behavior="scroll">scroll:表示由一端滚动到另一端,会重复。</marquee><marquee behavior="slide">slide: 表示由一端滚动到另一端,不会重复。</marquee>

3.3、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>

3.4、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>

3.5、宽度和高度

height:设定活动字幕的高度

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

width:设定活动字幕的宽度

<marquee width="500" bgcolor="#CCCCCC">设定活动字幕的宽度width="500"</marquee>

3.6、hspace:设定活动字幕里所在的位置距离父容器水平边框的距离

示例

<table width="500"border="1" align="center" cellpadding="0"cellspacing="0"><tr><td><marquee hspace="100"bgcolor="#CCCCCC">hspace="100"</marquee></td></tr></table>

3.7、vspace:设定活动字幕里所在的位置距离父容器垂直边框的距离

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

3.8、loop:设定滚动的次数,当loop=-1表示一直滚动下去,默认为-1

<marquee loop="-1"bgcolor="#CCCCCC">我会不停地走。</marquee><p>&nbsp;</p><marquee loop="2" bgcolor="#CCCCCC">我只走两次哦</marquee>

3.9、scrollamount:设定活动字幕的滚动速度,单位pixels

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

3.10、scrolldelay:设定活动字幕滚动两次之间的延迟时间,单位millisecond(毫秒)

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。