marquee 和JS 滚动效果
一、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.width、height:设定滚动字幕的宽度、高度
语法:<marquee width="500" height="200">...</marquee>
7.bgcolor:设定滚动字幕的背景颜色(可以是颜色值,也可以是rgb()或rgba()函数)
语法:<marquee bgcolor="rgba(0,0,0,0.2)">...</marquee>
8.hspace、vspace:空白空间(相当于设置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实现首尾相连循环滚动效果(): 代码如下: <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实现无缝滚动效果=================================
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>marquee测试</title>
- <script type="text/javascript" src="../../jquery/jquery.js"></script>
- <script type="text/javascript" src="../marquee/lib/jquery.marquee.js"></script>
- <script type="text/javascript">
- $(function(){
- $("#marquee").marquee({
- yScroll: "bottom",
- showSpeed: 850, // 初始下拉速度 ,
- scrollSpeed: 12, // 滚动速度 ,
- pauseSpeed: 500, // 滚动完到下一条的间隔时间 ,
- pauseOnHover: true, // 鼠标滑向文字时是否停止滚动 ,
- loop: -1 , // 设置循环滚动次数 (-1为无限循环) ,
- fxEasingShow: "swing" , // 缓冲效果 ,
- fxEasingScroll: "linear", // 缓冲效果 ,
- cssShowing: "marquee-showing" //定义class
- });
- });
- </script>
- <style>
- ul.marquee {
- display: block;
- line-height: 1;
- position: relative;
- overflow: hidden;
- width: 400px;
- height: 22px;
- }
- ul.marquee li {
- position: absolute;
- top: -999em;
- left: 0;
- display: block;
- white-space: nowrap;
- padding: 3px 5px;
- text-indent:0.8em
- }
- </style>
- </head>
- <body >
- <ul id="marquee" class="marquee">
- <li><a href="http://www.bloomylife.com/?cat=153" target="_blank">WEB前端开发</a> [2011-10-20]</li>
- <li><a href="http://www.bloomylife.com/?cat=154" target="_blank">架构设计</a> [2011-09-20]</li>
- <li><a href="http://www.bloomylife.com/?cat=157" target="_blank">系统运维</a> [2011-10-16]</li>
- </ul>
- </body>
- </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 滚动效果相关推荐
- 中奖人js滚动效果_jQuery实现中奖播报功能(让文本滚动起来) 简单设置数值即可...
在很多场景中,我们需要使用到中奖信息播报,或者一些文本信息循环滚动播报,在结合实际的开发中,然后也百度查询了相关的知识点,现在送上jQuery实现文本滚动. 1:html代码文件 相关使用说明也在页面 ...
- JQuery Marquee插件(无缝滚动效果)- marquee.js
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- jq 手风琴折叠菜单 js滚动效果 collapse.js slideUp()
功能类似 collapse.js 插件的效果 案例一,简单版本 <style>.hn_column a{color: #000;} .hn_column li{background:#cc ...
- 中奖人js滚动效果_js使用transition效果实现无缝滚动
作者:李大雷 出自:SegmentFault 思否 原文:segmentfault.com/a/1190000023945464 前言 无缝轮播一直是面试的热门题目,而大部分答案都是复制第一张到最后. ...
- 分别用marquee和div+js实现首尾相连循环滚动效果
分别用marquee和div+js实现首尾相连循环滚动效果,特效代码非常精简,仅3行实现! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 T ...
- html制作滚动游戏,HTML标签marquee实现滚动效果的简单方法(必看)
页面的自动滚动效果,可由javascript来实现,但是今天无意中发现了一个html标签 - 可以实现多种滚动效果,无需js控制. 使用marquee标记不仅可以移动文字,也可以移动图片,表格等. 语 ...
- vue内容横向循环滚动_Vue替代marquee标签超出宽度文字横向滚动效果
一.npm 安装 如果你想安装插件(自己写的) 安装 # install dependencies npm i marquee-components 使用 在main.js引入 import marq ...
- JS图片自动或者手动滚动效果(支持left或者up)
JS图片自动或者手动滚动效果 在谈组件之前 来谈谈今天遇到搞笑的事情,今天上午接到一个杭州电话 0571-28001187 即说是杭州人民法院的 貌似说我用招商银行信用卡在今年的6月23日借了招商银行 ...
- msclass 文字滚动_【JS特效】不间断滚动效果通用类
网上发现一个不错的js不间断滚动效果,今天来转载一下吧.这个js的作者应是崔永祥(因其博客已不存在,而无法确认),我这里只简单整理,只为笔记. ??? 需要通过样式,js来实现这个翻滚效果. ??? ...
最新文章
- 一个“复制/删除”方式的滚动
- 一次 SSH 攻击与处理小记
- 快速人体姿态估计--Pose Proposal Networks
- mysql修改配置文件内存后无法启动_记一次Oracle实例在修改内存大小后无法启动的惊悚经历...
- 如何将txt文档插入sql2000数据库
- MySQL 参数autoReconnect=true 解决8小时连接失效(转)
- Assigning to Classes CodeForces - 1300B
- jmeter html 乱码,jmeter压测学习14-jmeter返回内容中文乱码问题
- 转载——三种编程命名规范(匈牙利命名法、驼峰式命名法、帕斯卡命名法)...
- Job 存储和持久化 (第五部分)
- 配置codeblocks 的养眼colour theme ;鼠标颜色与型状配置,界面汉化,以及调试入门
- 挖金子修订版开发进行中
- Python解压zip和rar文件
- 微软/阿里/商汤等计算机视觉算法实习面经
- 爱心的数学函数方程_什么函数图像能构成爱心?
- 包包各部位名称图解_背包学问知多少 新手背包各部分功能详解
- 如何免费申请js.org二级域名
- 升级opengl和显卡驱动_opengl驱动 OpenGL版本或显卡驱动版本太低的解决方法介绍_网络-游戏圈...
- python Calendar日历模块函数介绍
- 【C语言程序设计】基本算术运算
热门文章
- 计算机_数据库_考研复试_简答题_全(2)
- 灵隐寺内的一幅对联,写尽了人的一生
- Android 高仿百度地图的LBS服务——离线地图篇 Part 2 (v 3.1.1)
- 21 步 教你成为一名成功的 Web 开发工程师
- Ra-01SC/Ra-01SCH模组驱动
- [Recap] ApacheCon North America 2019 完美谢幕
- T31Day2需求分析与设计
- python爬虫之抓取代理服务器IP
- Linux小小白入门教程(三):Linux文件夹
- 如何判断excel是2003还是2007版本