<marquee> 标签简介<marquee> 是 HTML 中实现文字或图片滚动效果的标签<marquee>这是滚动文字示例</marquee> |
|---|
属性 | 说明 | 示例 |
|---|---|---|
direction | 滚动方向 | left / right / up / down |
behavior | 滚动行为 | scroll(默认) / slide / alternate |
scrollamount | 滚动速度,数值越大越快 | scrollamount="10" |
scrolldelay | 滚动延迟(毫秒) | scrolldelay="50" |
loop | 循环次数 | loop="3"(0 表示无限循环) |
bgcolor | 背景颜色 | bgcolor="#f0f0f0" |
height / width | 高度和宽度 | height="50" / width="300" |
<marquee direction="left" scrollamount="5"> |
|---|
水平向左滚动文字 |
|---|
</marquee> |
|---|
<marquee direction="up" scrollamount="2" height="100"> |
|---|
垂直向上滚动文字 |
|---|
</marquee> |
|---|
<marquee behavior="alternate" scrollamount="3"> |
|---|
往返滚动文字 |
|---|
</marquee> |
|---|
<marquee loop="3"> |
|---|
文字滚动三次 |
|---|
</marquee> |
|---|
<marquee onmouseover="this.stop();" onmouseout="this.start();"> |
|---|
鼠标悬停时暂停滚动 |
|---|
</marquee> |
|---|
onmouseover → 鼠标悬停事件onmouseout → 鼠标移出事件<marquee>@keyframes + transform)CSS 滚动示例:
<div class="scroll-text">这是CSS滚动文字</div> |
|---|
<style> |
|---|
.scroll-text { |
|---|
display: inline-block; |
|---|
white-space: nowrap; |
|---|
animation: scroll-left 10s linear infinite; |
|---|
} |
|---|
@keyframes scroll-left { |
|---|
0% { transform: translateX(100%); } |
|---|
100% { transform: translateX(-100%); } |
|---|
} |
|---|
</style> |
|---|
✅ 现代网页更安全、灵活、兼容性好。
<marquee> 用于文字或图片滚动,支持 方向、速度、行为、循环 等属性https://www.52runoob.com/archives/6570
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。