HTML Marquee 标签

htmlweb developmentfront end technology更新于 2025/7/18 13:00:17

<marquee> 标签用于在网页上垂直或水平滚动文本或图像。例如,突发新闻、热门文章等。这些部分通常从左向右滚动显示。

注意:<marquee> 标签在 HTML5 中已弃用。

以下是属性:

属性
值
描述
behavior
scroll
slide
alternate
定义滚动的类型。
bgcolor
rgb(x,x,x)
#xxxxxx
colorname
已弃用 − 定义滚动内容的方向。
direction
up
down
left
right
定义滚动内容的方向。
height
pixels or %
定义字幕的高度。
hspace
pixels
指定字幕周围的水平空间。
loop
number
指定循环次数。默认值为 INFINITE,表示选取框无限循环。
scrolldelay
seconds
定义每次跳跃之间的延迟时间。
scrollamount
number
定义跳多远。
width
pixels or %
定义字幕的宽度。
vspace
pixels
指定字幕周围的垂直空间。

现在让我们看一个在 HTML 中实现 <marquee> 元素的示例:

示例

<!DOCTYPE html>
<html>
<head>
<title>HTML</title>
</head>
<body>
<h1>Demo Heading</h1>
<p>This is demo text.</p>
   <marquee direction = "right">This is moving text.</marquee>
</body>
</html>

这将产生以下输出。这是一个移动的文本:

文本从左向右移动:


相关文章


有用资源