本文主要介绍了jquery实现文字无缝滚动效果示例代码(marquee插件),具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。
推荐一个JQuery的无缝文字滚动效果,同时也可以滚动图片,也叫做跑马灯效果。
此jquery插件,依托jquery库,能实现各种滚动效果,且让HTML代码符合W3C标准。
使用方法如下:
1、加载javascript。
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.marquee.js"></script>
<script type="text/javascript">
$(function(){
$("#marquee").marquee({yScroll: "bottom"});
});
</script>2、加入CSS样式。
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;}3、HTML代码如下:
<ul id="marquee" > <li><a href="http://www.bloomylife.com/?cat=153" rel="external nofollow" target="_blank"> WEB前端开发</a> [2011-10-20]</li> <li><a href="http://www.bloomylife.com/?cat=154" rel="external nofollow" target="_blank"> 架构设计</a> [2011-09-20]</li> <li><a href="http://www.bloomylife.com/?cat=157" rel="external nofollow" target="_blank"> 系统运维</a> [2011-10-16]</li> </ul>
该插件提供了许多属性选项,您可以配置定制外观和效果。
{
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 // 滚动完了回调函数
}jquery.marquee.js可以到官网地址下载:http://www.givainc.com/labs/marquee_jquery_plugin.htm
相关推荐:
实例详解jQuery实现手风琴菜单、层级菜单、置顶菜单、无缝滚动效果
以上就是JQuery文字无缝滚动效果实现方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号