会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
博客园
首页
新随笔
联系
订阅
管理
随笔 - 338
文章 - 0
评论 - 1081
阅读 -
228万
jQuery插件-轻量图片轮换-UISlide2
UISlide 的不同效果展现:
<!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" xml:lang="en"> <head> <title>UISlideDemo1.0</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <!--<script type="text/javascript" src="http://www.cnblogs.com/jquery-1.4.4.min.js"></script>--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <!--<script type="text/javascript" src="js/jquery.easing.js"></script>--> <script type="text/javascript" src="http://jquery-swip.googlecode.com/svn/trunk/jquery.easing.1.3.js"></script> <!--<script type="text/javascript" src="js/jquery.UISlide2.js"></script>--> <style type="text/css"> *{ margin:0;padding:0;} body{font:12px/2 arial;background:#ccc;} a{color:#0029c4;text-decoration:none;} a:hover{color:#c00;} img{border:none 0;} .wrap{width:714px;margin:40px auto;border:2px solid #aaa;background:#fff;padding:5px 5px 0;} .slide_wrap{position:relative;width:710px;height:340px; margin-bottom:5px;border:2px solid #ccc;background:#fff;color:#666;overflow:hidden;} .slide_imglist{} /*.slide_imglist li{float:left;margin-right:3px;display:inline;}*/ .slide_imglist li{ float:left;margin-right:3px;display:inline;} .slide_imglist li img{width:710px;height:340px;display:block;} .slide_title{bottom:0;left:0;width:100%;height:45px;overflow:hidden;position:absolute;} .slide_title h3{position:absolute;top:0;left:0;height:45px;line-height:45px;overflow:hidden;padding:0 10px;z-index:2;display:block;} .slide_title h3 a{color:#efefef;font-weight:bold;font-size:16px;} .slide_title h3 a:hover{color:#ff0;} .slide_title em{position:absolute;left:0;display:block;top:0;width:100%;height:45px;opacity:0.45;filter:alpha(opacity=45);background:#000;z-index:1;} .slide_num{right:5px;z-index:3;top:0;position:absolute;} .slide_num dd{display:inline;margin:10px 4px 0 0;width:22px;height:22px;font-size:14px;text-align:center;line-height:22px;border:1px #eee solid;background:#d4d4d4;cursor:pointer;float:left;} .slide_num dd.active{color:#fff;border:1px #09f solid;background:#09f;} </style> </head> <body> <div class="wrap"> <div id="slide" class="slide_wrap"> <ul class="slide_imglist"> <li><a title="《画皮Ⅱ》正式版预告首发 魔幻大作妖魅来袭" href="http://fanbuxie.vancl.com/" target="_blank"><img src="http://i4.vanclimg.com/users/26/20120318/focus_1_120318.jpg" alt="" /></a></li> <li><a title="《普罗米修斯》全新中文预告首发 科幻大作终现全貌" href="http:////rihan.vancl.com/" target="_blank"><img src="http://i1.vanclimg.com/users/26/20120315/focus_6_3n_cs_120315.jpg" alt="" /></a></li> <li><a title="诡异华美缜密悬疑:12大日本推理名家改编宝典" href="http://children.vancl.com/search?navtype=08&attrid_category_attributes=7939" target="_blank"><img src="http://i2.vanclimg.com/users/26/20120321/focus_tz_120321_nn.jpg" alt="" /></a></li> </ul> <div class="slide_title"> <h3><a href="#" target="_blank">设计好脾气的Web页面</a></h3> <dl class="slide_num"></dl> <em></em> </div> </div> <!--/slide--> <div id="slide2" class="slide_wrap"> <ul class="slide_imglist"> <li><a title="现代主妇vs职业女性:从 "广告狂人" 看60年代女性风尚" href="http://vt.vancl.com/" target="_blank"><img src="http://i5.vanclimg.com/users/26/20120316/foucs_2_4_vt_201203016n.jpg" alt="" /></a></li> <li><a title="诡异华美缜密悬疑:12大日本推理名家改编宝典" href="http://xiuxianku.vancl.com/" target="_blank"><img src="http://i3.vanclimg.com/users/26/20120318/focus_5_120318.jpg" alt="" /></a></li> <li><a title="2012佳片鉴赏录:25部奥斯卡种子影片超前瞻" href="http://nanxie.vancl.com/" target="_blank"><img src="http://i2.vanclimg.com/users/26/20120320/focus_6_n_120320.jpg" alt="" /></a></li> </ul> <div class="slide_title"> <h3><a href="#" target="_blank">设计好脾气的Web页面</a></h3> <dl class="slide_num"></dl> <em></em> </div> </div> <!--/slide--> </div> <script type="text/javascript"> /** * Copyright (c) 2011 Jikeytang (http://jikey.cnblog.com/) * Version: 0.0.1 * Demo: http://jikey.cnblog.com/ */ ;(function($){ // 图片轮播插件 $.fn.UISlide = function(options){ var defaults = { playTime :3000, // 间隔时间 duration :800, // 延迟时间 direction :'left', // 方向 easing :'easeInOutQuad', // 自动播放时 easing 方式 clickEasing :'easeOutCubic', // 点击时 easing 方式 pattern :'scroll' }; var opts = $.extend({}, defaults, options); // 参数合并 var slide = { // 播放调用及一些变量的初始化 play: function(opts, me){ var that = this, isPlay; that.me = me; that.picList = me.find('ul'); // 图片列表 that.title = me.find('div').find('a'); // 图片标题 that.oNum = me.find('dl'); // 数字按钮 that.lis = that.picList.find('li'); // li that.size = that.lis.length; // 图片的数量 that.lisWidth = that.lis.width(); that.isPlay = isPlay; // 是否自动播放 for (var p in opts) { // opts 绑定到 slide that[p] = opts[p]; } that.setNums().setTitle(); if(that.pattern == 'fade'){ that.lis.css({position: 'absolute', top: 0, left: 0}); that.lis.css('z-index', 1); } // 如果图片数量大于则轮播 that.size > 1 && that.autoPlay().slideEvent(); }, // 设置按钮 setNums: function(){ var that = this, links, // 图片的链接 me = that.me, size = that.size, oNum = that.oNum, // 按钮对象 arrTemp = []; links = that.picList.find('a').first(); that.title.html(links[0].title).attr('href', links[0].href); // 把链接的 title 内容放到标题栏上显示 for(var i=1; i<=size; i++){ // 借鉴司徒正美兄: http://www.cnblogs.com/rubylouvre/archive/2009/07/24/1530264.html 的写法 arrTemp.push('<dd>' + i + '</dd>'); } oNum.append(arrTemp.join('')); that.slideNum = oNum.find('dd'); that.numWidth = (that.slideNum.width() + parseInt(that.slideNum.css('margin-right')) + 2) * size + 1; // 数字按钮宽度 that.setTitle(); // 底部图片标题设置 return that; }, // 自动播放 autoPlay: function(){ var that = this, activePos, direction = that.direction, picList = that.picList, slideNum = that.slideNum, playTime = that.playTime; that.isPlay = setInterval(function (){ activePos = that.oNum.find('.active').index(); // 在数字按钮中找到当前活动标签的所在位置 // console.log('size', that.size); if(activePos < (that.size - 1)){ // direction = 'right'; activePos ++; } else if(activePos == (that.size - 1)){ activePos = 0; } else{ activePos --; } if(that.pattern == 'scroll'){ picList.stop().animate({'margin-left': 0 - activePos * (that.lisWidth + 3)}, {duration: that.duration, easing: that.easing}); } else { that.lis.stop().animate({opacity: 0}, {duration: that.duration, easing: that.easing}); that.lis.eq(activePos).stop().animate({opacity: 1}, {duration: that.duration, easing: that.easing}); } slideNum.removeClass('active').eq(activePos).addClass('active'); var links = picList.find('a').eq(activePos); that.title.html(links[0].title).attr('href', links[0].href); }, playTime); return that; }, // 设置标题 setTitle: function(){ var that = this; that.oNum.width(that.numWidth + 2); // 设置数字按钮宽度 that.picList.width((that.lisWidth + 3) * that.size); // 设置图片容器总宽度 that.slideNum.first().addClass('active'); return that; }, // 绑定数字按钮事件 slideEvent: function(){ var that = this, slideNum = that.slideNum; slideNum.click(function(){ var thisNum = $(this).index(); if(that.pattern == 'scroll'){ that.picList.stop().animate({"margin-left":0 - thisNum * (that.lisWidth + 3)}, {duration:that.duration, easing:that.clickEasing}); } else { that.lis.stop().animate({opacity: 0}, {duration: that.duration, easing: that.easing}); that.lis.eq(thisNum).stop().animate({opacity: 1}, {duration: that.duration, easing: that.easing}); } slideNum.removeClass('active').eq(thisNum).addClass('active'); var links = that.picList.find('a').eq(thisNum); that.title.html(links[0].title).attr('href', links[0].href); }); // 鼠标到画面中任意位置,停止播放 that.me.hover(function(){ clearInterval(that.isPlay); }, function(){ that.autoPlay(); }) return that; } }; return this.each(function(){ // $(a,b) 方式调用 slide.play(opts, $(this)); }); } })(jQuery); $('#slide2').UISlide(); $('#slide').UISlide({ playTime: 3000, duration: 1500, pattern: 'fade' }); </script> </body> </html>
运行代码
分类:
Jquery
好文要顶
关注我
收藏该文
微信分享
豪情
粉丝 -
3291
关注 -
43
+加关注
1
0
升级成为会员
«
上一篇:
豪情作品
»
下一篇:
Js,jQuery版Zencoding之webstorm & phpstorm
posted @
2012-03-27 14:42
豪情
阅读(
1872
) 评论(
1
)
编辑
收藏
举报
刷新页面
返回顶部
登录后才能查看或发表评论,立即
登录
或者
逛逛
博客园首页
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
编辑推荐:
·
如何编写易于单元测试的代码
·
10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
·
.NET Core 中如何实现缓存的预热?
·
从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
·
AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
·
周边上新:园子的第一款马克杯温暖上架
·
Open-Sora 2.0 重磅开源!
·
.NET周刊【3月第1期 2025-03-02】
·
分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
·
[AI/GPT/综述] AI Agent的设计模式综述
公告
昵称:
豪情
园龄:
15年3个月
粉丝:
3291
关注:
43
+加关注
<
2012年3月
>
日
一
二
三
四
五
六
26
27
28
29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
搜索
我的标签
Javascript高程第二版--笔记
(12)
javascript
(9)
zen coding
(5)
WebStorm
(4)
css
(3)
精通javascript
(3)
JavaScriptDOM高级程序设计
(2)
资源
(2)
网址导航
(2)
zp
(1)
更多
随笔分类
(339)
CSS(32)
JavaScript(159)
Jquery(35)
Month(9)
Other(53)
PHP(3)
SublimeText(4)
Tool(13)
UI(12)
Vim(4)
Vue(2)
WebStorm/PhpStorm(13)
随笔档案
(337)
2019年5月(2)
2016年2月(1)
2016年1月(1)
2015年11月(1)
2015年10月(2)
2015年9月(3)
2015年7月(1)
2015年6月(1)
2015年5月(1)
2015年4月(3)
2015年2月(1)
2015年1月(5)
2014年12月(4)
2014年11月(8)
2014年10月(8)
2014年9月(1)
2014年6月(1)
2014年3月(9)
2014年1月(1)
2013年12月(3)
2013年5月(1)
2013年4月(4)
2013年3月(8)
2013年1月(1)
2012年12月(4)
2012年11月(1)
2012年10月(2)
2012年8月(4)
2012年7月(3)
2012年6月(1)
2012年4月(2)
2012年3月(8)
2012年2月(3)
2012年1月(1)
2011年12月(6)
2011年11月(1)
2011年7月(3)
2011年6月(5)
2011年5月(1)
2011年4月(1)
2011年3月(12)
2011年2月(1)
2011年1月(2)
2010年12月(7)
2010年11月(2)
2010年10月(5)
2010年9月(7)
2010年8月(14)
2010年7月(10)
2010年6月(14)
2010年5月(46)
2010年4月(19)
2010年3月(19)
2010年2月(7)
2010年1月(7)
2009年12月(48)
更多
link
豪情-Java
james
stevenlevithan
paulirish--jquery team
我是程序员
Aaron
VaJoy Larn
阅读排行榜
1. 1. web前端开发分享-css,js入门篇(168106)
2. web前端开发分享-目录(120242)
3. 如何在Webstorm/Phpstorm中设置连接FTP,并快速进行文件比较,上传下载,同步等操作(113116)
4. 前端开发利器webStorm 3.0配置使用(105933)
5. 4. web前端开发分享-css,js工具篇(94351)
6. 在sublime-text中设置浏览器预览(83304)
7. 我们前端跟后端是怎么合作的(80429)
8. JS的构造函数(74046)
9. 超强JavaScript编辑器webstorm主题(theme)(68478)
10. 我们前端是怎么找到工作的(66026)
评论排行榜
1. JS高级前端开发群加群说明及如何晋级(67)
2. 豪情-2015年阅读书籍分享[上](57)
3. 网上分享知识和帮助他人,自己有什么收获?(53)
4. 经典黑色--网站管理界面(38)
5. 我们前端是怎么找到工作的(34)
6. 豪情-关于生活工作学习之感悟-第一篇(33)
7. 前端应聘要准备些什么样子的作品?(29)
8. css 填坑常用代码分享(29)
9. 超强JavaScript编辑器webstorm主题(theme)(29)
10. 年后跳槽如何准备?(28)
推荐排行榜
1. 我们前端是怎么找到工作的(77)
2. web前端开发分享-目录(74)
3. 豪情-关于生活工作学习之感悟-第一篇(54)
4. 年后跳槽如何准备?(53)
5. css 填坑常用代码分享(51)
最新评论
1. Re:超强JavaScript编辑器webstorm主题(theme)
现在还能用吗?在win10上?
--香荣如梦
2. Re:豪情-2014年年终总结
向豪哥学习
--王小伞
3. Re:JS高级前端开发群加群说明及如何晋级
上海-时间前来报道
--你灬哪位
4. Re:6. web前端开发分享-css,js移动篇
感谢
--不爱学习不爱运动
5. Re:我们前端跟后端是怎么合作的
时至今日偶然看见此片老文章,读着评论,感觉像和古人交互一样,这种感觉如同穿越一般,令人着迷啊。
--LBAMSG_1
点击右上角即可分享
AI IDE Trae
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述