HTML的<marquee>标签

在这里插入图片描述
在MDN上看到这句话,对我这个小白来说实在是有点难受,好 nb 的一个标签为啥废弃了呢,还想学会装装 b 呢, 不管,不管,废弃了也要学。

属性作用
behaviorscroll(默认值) / slide / alternate设置文本在 marquee 元素内如何滚动
bgcolorcolor / #…设置背景颜色
directionleft(默认值) / right / up / down设置 marquee 内文本滚动的方向
heightpx / percent以像素或百分比值设置高度
hspacepx / percent设置水平边距
loop−1 (默认值连续滚动) / n (数字)设置 marquee 滚动的次数
scrollamount6(默认值)设置每次滚动时移动的长度(以像素为单位)
scrolldelay85(默认值)设置每次滚动时的时间间隔. 除非指定 truespeed 值,否则将忽略任何小于 60 的值,并将其改为使用 60
truespeed数字默认情况下,会忽略小于60的scrolldelay值。如果存在truespeed,那些值不会被忽略。
vspacepx / percent设置垂直边距
widthpx / percent设置宽度

栗子:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 可以移动文字、图片、表格等 -->
    <marquee direction="up" behavior="alternate" scrollamount="50" scrolldelay="200" loop="2" width="400px" height="700px" bgcolor="red" hspace="" vspace="0"><br><br></marquee>
    <marquee direction="left" scrollamount="50" scrolldelay="1000"><br><br></marquee>
</body>

</html>

事件回调

  1. onbounce
    当 marquee 滚动到结尾时触发。它只能在 behavior 属性设置为 alternate 时触发。
  2. onfinish
    当 marquee 完成 loop 属性设置的值时触发。它只能在 loop 属性设置为大于 0 的某个数字时触发。
    onstart
  3. 当 marquee 开始滚动时触发。

方法

  1. start
    开始滚动 marquee。
  2. stop
    停止滚动 marquee。

MDN上的栗子:

<marquee>This text will scroll from right to left</marquee>

<marquee direction="up">This text will scroll from bottom to top</marquee>

<marquee direction="down" width="250" height="200" behavior="alternate" style="border:solid">
  <marquee behavior="alternate">
    This text will bounce
  </marquee>
</marquee>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值