| 屬性 | 說明 | 範例值 |
|---|---|---|
| behavior | 滾動方式 | scroll(預設) / slide / alternate |
| direction | 滾動方向 | left / right / up / down |
| scrollamount | 每步像素 | 1~10 |
| scrolldelay | 延遲毫秒 | 60 |
| loop | 重複次數 | -1(無限) / 數字 |
| width/height | 區域大小 | px 或 % |
| hspace/vspace | 水平/垂直邊距 | 像素 |
| bgcolor | 背景色 | #RRGGBB |
<script>
var content = '<strong>歡迎訪問<a href="https://example.com">範例網站</a></strong>';
document.write('<marquee scrollamount="4">' + content + '</marquee>');
</script>
<marquee behavior="scroll" direction="up" width="130" height="80"
scrollamount="1" scrolldelay="60"
onmouseover="this.stop()" onmouseout="this.start()">
<p><a href="#">畢業班學生下周離校</a></p>
<p><a href="#">7月10日放暑假</a></p>
<p><a href="#">省水利年會在我校召開</a></p>
</marquee>
.marquee { overflow: hidden; white-space: nowrap; }
.marquee span { display: inline-block; animation: marquee 10s linear infinite; }
.marquee:hover span { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(100%); } to { transform: translateX(-100%); } }
優點:GPU 加速、無障礙友善、可暫停、支援垂直/水平、無相容性問題。
<marquee> 為非標準標籤,HTML5 已棄用,部分瀏覽器未來可能移除。