一、marquee标签的几个重要属性:

1.direction:滚动方向(包括4个值:up、down、left、right)

说明:up:从下向上滚动;down:从上向下滚动;left:从右向左滚动;right:从左向右滚动。

语法:<marquee direction="滚动方向">...</marquee>

2.behavior:滚动方式(包括3个值:scroll、slide、alternate)

说明:scroll:循环滚动,默认效果;slide:只滚动一次就停止;alternate:来回交替进行滚动。

语法:<marquee behavior="滚动方式">...</marquee>

3.scrollamount:滚动速度(滚动速度是设置每次滚动时移动的长度,以像素为单位)

语法:<marquee scrollamount="5">...</marquee>

4.scrolldelay:设定滚动两次之间的延迟时间,值大了会有一步一停顿的效果(设置滚动的时间间隔,单位是毫秒)

语法:<marquee scrolldelay="100">...</marquee>

5.loop:设定滚动循环的次数(默认值是-1,滚动会不断的循环下去)

语法:<marquee loop="2">...</marquee>

<marquee loop="-1" bgcolor="#CCCCCC">我会不停地走。</marquee>

<marquee loop="2" bgcolor="#CCCCCC">我只走两次哦</marquee>

6.widthheight:设定滚动字幕的宽度、高度

语法:<marquee width="500" height="200">...</marquee>

7.bgcolor:设定滚动字幕的背景颜色(可以是颜色值,也可以是rgb()或rgba()函数)

语法:<marquee bgcolor="rgba(0,0,0,0.2)">...</marquee>

8.hspacevspace:空白空间(相当于设置margin值)

说明:hspace:设定活动字幕里所在的位置距离父容器水平边框的距离,如hspace=“10”,即等同于:margin:0 10px;

vspace:设定活动字幕里所在的位置距离父容器垂直边框的距离,如vspace=“10”,即等同于:margin:10px 0;

语法:<marquee hspace="10"  vspace="10">...</marquee>(等同于:margin:10px;)

9.align:设定滚动字幕内容的对齐方式(包括9个值:absbottom、absmiddle、baseline、bottom、left、middle、right、                                       texttop、top)

说明:absbottom:绝对底部对齐(与g、p等字母的最下端对齐)
                          absmiddle:绝对中央对齐
                          baseline:底线对齐
                          bottom:底部对齐(默认)
                          left:左对齐
                          middle:中间对齐
                          right:右对齐
                          texttop:顶线对齐
                          top:顶部对齐

语法:<marquee align="对齐方式">...</marquee>

10.face:设定滚动字幕的文字字体

语法:<marquee font="楷体_GB2312"></marquee>

11.color:设定滚动字幕的文字颜色

语法:<marquee color="#333"></marquee>

12.size:设定滚动字幕的文字字号

语法:<marquee size="3"></marquee>

13.STRONG:设定滚动字幕的文字加粗

语法:<marquee STRONG></marquee>

二、marquee常用到的两个事件:
               onMouseOut="this.start()" 用来设置鼠标移出该区域时继续滚动
               onMouseOver="this.stop()" 用来设置鼠标移入该区域时停止滚动

<marquee onMouseOut="this.start()" onMouseOver="this.stop()">marquee常用到的两个事件</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()">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<div>
<marquee direction="up" behavior="scroll" scrollamount="1" scrolldelay="0" loop="-1" width="1000" height="50" bgcolor="#0099FF" hspace="10" vspace="10">
指整个Marquee对齐方式; (2)behavior:设置滚动的方式: scroll:表示由一端滚动到另一端,会重复,缺陷是不能无缝滚动。 slide:表示由一段滚动到另一端,不会重复...
</marquee>
</div>
</body>
</html>

marquee 标签的鼠标放上去滚动效果 鼠标离开继续滚动

这也是笔者刚发现的一个marquee的写法,应该说这个效果很实用,可以轻松的实现鼠标放上去停止滚动、鼠标离开继续滚动的效果。下面是具体的用法(特别注意onMouseOver和onMouseOut是需要同时写进去才会出现比较好的效果):onMouseOut="this.start()" :用来设置鼠标移出该区域时继续滚动onMouseOver="this.stop()":用来设置鼠标移入该区域时停止滚动
代码如下:
<marquee onMouseOut="this.start()" onMouseOver="this.stop()">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>
该标签支持的属性多达11个:
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>
behavior 设定滚动的方式: alternate: 表示在两端之间来回滚动。 scroll: 表示由一端滚动到另一端,会重复。 slide:  表示由一端滚动到另一端,不会重复。
代码如下:
<marquee behavior="alternate">alternate:表示在两端之间来回滚动。 </marquee> <marquee behavior="scroll">scroll:表示由一端滚动到另一端,会重复。</marquee> <marquee behavior="slide">slide:  表示由一端滚动到另一端,不会重复。</marquee>
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>
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>
height 设定活动字幕的高度
代码如下: <marquee height="500" direction="down" bgcolor="#CCCCCC">设定活动字幕的高度height="500"</marquee>
width 设定活动字幕的宽度
代码如下: <marquee width="500" bgcolor="#CCCCCC">设定活动字幕的宽度width="500"</marquee>
hspace 设定活动字幕里所在的位置距离父容器水平边框的距离 This controls the horizontal(水平)space around the display box.
代码如下:
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0"><tr><td><marquee hspace="100" bgcolor="#CCCCCC">hspace="100"</marquee></td></tr></table>
vspace 设定活动字幕里所在的位置距离父容器垂直边框的距离 This controls the vertical(垂直) space around the display box.
代码如下: <marquee vspace="100" bgcolor="#CCCCCC">hspace="100"</marquee>
loop 设定滚动的次数,当loop=-1表示一直滚动下去,默认为-1
代码如下:
<marquee loop="-1" bgcolor="#CCCCCC">我会不停地走。</marquee> <p>&nbsp;</p> <marquee loop="2" bgcolor="#CCCCCC">我只走两次哦</marquee>
scrollamount 设定活动字幕的滚动速度,单位pixels
代码如下:
<marquee scrollamount="10" >scrollamount="10" </marquee> <marquee scrollamount="20" >scrollamount="20" </marquee> <marquee scrollamount="30" >scrollamount="30" </marquee>
scrolldelay 设定活动字幕滚动两次之间的延迟时间,单位millisecond(毫秒) 值大了会有一步一停顿的效果
代码如下:
<marquee scrolldelay="10" >scrolldelay="10" </marquee> <marquee scrolldelay="100" > scrolldelay="100"</marquee> <marquee scrolldelay="1000">scrolldelay="1000" </marquee>
===============================================================================
marquee实现首尾相连循环滚动效果(): 代码如下:
<marquee behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100" οnmοuseοver="this.stop();" οnmοuseοut="this.start();">
这里是要滚动的内容
</marquee>
======================基本示例====================================================
<marquee direction="down" loop="-1" truespeed="truespeed" height="300px" behavior="scroll" scrollamount="3" scrolldelay="100">
        <p><a href="">hellohellohellohellohellohellohellohellohellohello</a></p>
        <p>hellohellohellohellohellohellohellohellohellohello</p>
        <p>hellohellohellohellohellohellohellohellohellohello</p>
        <p>hellohellohellohellohellohellohellohellohellohello</p>
        <p>hellohellohellohellohellohellohellohellohellohello</p>
        <p>hellohellohellohellohellohellohellohellohellohello</p>
        <p>hellohellohellohellohellohellohellohellohellohello</p>

</marquee>
=============================以下是JS实现无缝滚动效果=================================
  
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>marquee测试</title>
  6. <script type="text/javascript" src="../../jquery/jquery.js"></script>
  7. <script type="text/javascript" src="../marquee/lib/jquery.marquee.js"></script>
  8. <script type="text/javascript">
  9. $(function(){
  10. $("#marquee").marquee({
  11. yScroll: "bottom",
  12. showSpeed: 850,        // 初始下拉速度         ,
  13. scrollSpeed: 12,       // 滚动速度         ,
  14. pauseSpeed: 500,      // 滚动完到下一条的间隔时间         ,
  15. pauseOnHover: true,    // 鼠标滑向文字时是否停止滚动         ,
  16. loop: -1 ,             // 设置循环滚动次数 (-1为无限循环)         ,
  17. fxEasingShow: "swing" , // 缓冲效果         ,
  18. fxEasingScroll: "linear",  // 缓冲效果         ,
  19. cssShowing: "marquee-showing"  //定义class
  20. });
  21. });
  22. </script>
  23. <style>
  24. ul.marquee {
  25. display: block;
  26. line-height: 1;
  27. position: relative;
  28. overflow: hidden;
  29. width: 400px;
  30. height: 22px;
  31. }
  32. ul.marquee li {
  33. position: absolute;
  34. top: -999em;
  35. left: 0;
  36. display: block;
  37. white-space: nowrap;
  38. padding: 3px 5px;
  39. text-indent:0.8em
  40. }
  41. </style>
  42. </head>
  43. <body >
  44. <ul id="marquee" class="marquee">
  45. <li><a href="http://www.bloomylife.com/?cat=153" target="_blank">WEB前端开发</a> [2011-10-20]</li>
  46. <li><a href="http://www.bloomylife.com/?cat=154" target="_blank">架构设计</a> [2011-09-20]</li>
  47. <li><a href="http://www.bloomylife.com/?cat=157" target="_blank">系统运维</a> [2011-10-16]</li>
  48. </ul>
  49. </body>
  50. </html>
该插件提供了许多属性选项,您可以配置定制外观和效果。
  • {
  • yScroll: "top"        // 初始滚动方向 (还可以是"top" 或 "bottom")         ,
  • showSpeed: 850        // 初始下拉速度         ,
  • scrollSpeed: 12       // 滚动速度         ,
  • pauseSpeed: 5000      // 滚动完到下一条的间隔时间         ,
  • pauseOnHover: true    // 鼠标滑向文字时是否停止滚动         ,
  • loop: -1              // 设置循环滚动次数 (-1为无限循环)         ,
  • fxEasingShow: "swing"  // 缓冲效果         ,
  • fxEasingScroll: "linear"  // 缓冲效果         ,
  • cssShowing: "marquee-showing"  //定义class           //
  • event handlers         ,
  • init: null                // 初始调用函数         ,
  • beforeshow: null           // 滚动前回调函数         ,
  • show: null                 // 当新的滚动内容显示时回调函数         ,
  • aftershow: null            // 滚动完了回调函数
本文参考多位博友文章:在此谢过!

marquee 和JS 滚动效果相关推荐

  1. 中奖人js滚动效果_jQuery实现中奖播报功能(让文本滚动起来) 简单设置数值即可...

    在很多场景中,我们需要使用到中奖信息播报,或者一些文本信息循环滚动播报,在结合实际的开发中,然后也百度查询了相关的知识点,现在送上jQuery实现文本滚动. 1:html代码文件 相关使用说明也在页面 ...

  2. JQuery Marquee插件(无缝滚动效果)- marquee.js

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  3. jq 手风琴折叠菜单 js滚动效果 collapse.js slideUp()

    功能类似 collapse.js 插件的效果 案例一,简单版本 <style>.hn_column a{color: #000;} .hn_column li{background:#cc ...

  4. 中奖人js滚动效果_js使用transition效果实现无缝滚动

    作者:李大雷 出自:SegmentFault 思否 原文:segmentfault.com/a/1190000023945464 前言 无缝轮播一直是面试的热门题目,而大部分答案都是复制第一张到最后. ...

  5. 分别用marquee和div+js实现首尾相连循环滚动效果

    分别用marquee和div+js实现首尾相连循环滚动效果,特效代码非常精简,仅3行实现! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 T ...

  6. html制作滚动游戏,HTML标签marquee实现滚动效果的简单方法(必看)

    页面的自动滚动效果,可由javascript来实现,但是今天无意中发现了一个html标签 - 可以实现多种滚动效果,无需js控制. 使用marquee标记不仅可以移动文字,也可以移动图片,表格等. 语 ...

  7. vue内容横向循环滚动_Vue替代marquee标签超出宽度文字横向滚动效果

    一.npm 安装 如果你想安装插件(自己写的) 安装 # install dependencies npm i marquee-components 使用 在main.js引入 import marq ...

  8. JS图片自动或者手动滚动效果(支持left或者up)

    JS图片自动或者手动滚动效果 在谈组件之前 来谈谈今天遇到搞笑的事情,今天上午接到一个杭州电话 0571-28001187 即说是杭州人民法院的 貌似说我用招商银行信用卡在今年的6月23日借了招商银行 ...

  9. msclass 文字滚动_【JS特效】不间断滚动效果通用类

    网上发现一个不错的js不间断滚动效果,今天来转载一下吧.这个js的作者应是崔永祥(因其博客已不存在,而无法确认),我这里只简单整理,只为笔记. ??? 需要通过样式,js来实现这个翻滚效果. ??? ...

最新文章

  1. 一个“复制/删除”方式的滚动
  2. 一次 SSH 攻击与处理小记
  3. 快速人体姿态估计--Pose Proposal Networks
  4. mysql修改配置文件内存后无法启动_记一次Oracle实例在修改内存大小后无法启动的惊悚经历...
  5. 如何将txt文档插入sql2000数据库
  6. MySQL 参数autoReconnect=true 解决8小时连接失效(转)
  7. Assigning to Classes CodeForces - 1300B
  8. jmeter html 乱码,jmeter压测学习14-jmeter返回内容中文乱码问题
  9. 转载——三种编程命名规范(匈牙利命名法、驼峰式命名法、帕斯卡命名法)...
  10. Job 存储和持久化 (第五部分)
  11. 配置codeblocks 的养眼colour theme ;鼠标颜色与型状配置,界面汉化,以及调试入门
  12. 挖金子修订版开发进行中
  13. Python解压zip和rar文件
  14. 微软/阿里/商汤等计算机视觉算法实习面经
  15. 爱心的数学函数方程_什么函数图像能构成爱心?
  16. 包包各部位名称图解_背包学问知多少 新手背包各部分功能详解
  17. 如何免费申请js.org二级域名
  18. 升级opengl和显卡驱动_opengl驱动 OpenGL版本或显卡驱动版本太低的解决方法介绍_网络-游戏圈...
  19. python Calendar日历模块函数介绍
  20. 【C语言程序设计】基本算术运算

热门文章

  1. 计算机_数据库_考研复试_简答题_全(2)
  2. 灵隐寺内的一幅对联,写尽了人的一生
  3. Android 高仿百度地图的LBS服务——离线地图篇 Part 2 (v 3.1.1)
  4. 21 步 教你成为一名成功的 Web 开发工程师
  5. Ra-01SC/Ra-01SCH模组驱动
  6. [Recap] ApacheCon North America 2019 完美谢幕
  7. T31Day2需求分析与设计
  8. python爬虫之抓取代理服务器IP
  9. Linux小小白入门教程(三):Linux文件夹
  10. 如何判断excel是2003还是2007版本