jQuery图片播放插件ColorBox使用方法
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:admin 阅读 692
昨天给大家介绍了一款功能很强大的jquery图片播放插件Fancybox,今天虽然比较晚了,但笔者依然有冲动要继续给大家介绍一款好用的jquery图片播放插件ColorBox,希望对大家平时的Web

昨天给大家介绍了一款功能很强大的jquery图片播放插件Fancybox,今天虽然比较晚了,但笔者依然有冲动要继续给大家介绍一款好用的jquery图片播放插件ColorBox,希望对大家平时的Web编程有所帮助。

ColorBox插件的项目主页地址:http://colorpowered.com/colorbox/

最新版本ColorBox插件下载地址:http://colorpowered.com/colorbox/latest

ColorBox插件演示地址,这里ColorBox提供了5种漂亮的皮肤,大家可以分别去看看各种皮肤的demo

皮肤一演示地址:http://colorpowered.com/colorbox/core/example1/index.html

皮肤二演示地址:http://colorpowered.com/colorbox/core/example2/index.html

皮肤三演示地址:http://colorpowered.com/colorbox/core/example3/index.html

皮肤四演示地址:http://colorpowered.com/colorbox/core/example4/index.html

皮肤五演示地址:http://colorpowered.com/colorbox/core/example5/index.html

这个插件一个最大的特点就是“小”,整个js脚本才10KB,看了上面的演示你可能无法相信如此强大的东西才10KB,但我不得不告诉你,没错,它就是这么强悍。

下面就简单来讲讲ColorBox的使用方法。

1、引入jquery核心库和ColorBox脚本文件

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="../colorbox/jquery.colorbox.js"></script>

2、引入ColorBox样式表文件,注意引入不同皮肤的css文件将实现不同的皮肤

<link media="screen" rel="stylesheet" href="colorbox.css" />

3、html代码

<h2>弹性效果</h2>
<p><a href="../content/ohoopee1.jpg" rel="example1" title="Me and my grandfather on the Ohoopee.">Grouped Photo 1</a></p>
<p><a href="../content/ohoopee2.jpg" rel="example1" title="On the Ohoopee as a child">Grouped Photo 2</a></p>
<p><a href="../content/ohoopee3.jpg" rel="example1" title="On the Ohoopee as an adult">Grouped Photo 3</a></p>

<h2>淡入淡出效果</h2>
<p><a href="../content/ohoopee1.jpg" rel="example2" title="Me and my grandfather on the Ohoopee">Grouped Photo 1</a></p>
<p><a href="../content/ohoopee2.jpg" rel="example2" title="On the Ohoopee as a child">Grouped Photo 2</a></p>
<p><a href="../content/ohoopee3.jpg" rel="example2" title="On the Ohoopee as an adult">Grouped Photo 3</a></p>

<h2>没有动画效果,高度固定(屏幕大小的75%)</h2>
<p><a href="../content/ohoopee1.jpg" rel="example3" title="Me and my grandfather on the Ohoopee.">Grouped Photo 1</a></p>
<p><a href="../content/ohoopee2.jpg" rel="example3" title="On the Ohoopee as a child">Grouped Photo 2</a></p>
<p><a href="../content/ohoopee3.jpg" rel="example3" title="On the Ohoopee as an adult">Grouped Photo 3</a></p>

<h2>自动播放</h2>
<p><a href="../content/ohoopee1.jpg" rel="example4" title="Me and my grandfather on the Ohoopee.">Grouped Photo 1</a></p>
<p><a href="../content/ohoopee2.jpg" rel="example4" title="On the Ohoopee as a child">Grouped Photo 2</a></p>
<p><a href="../content/ohoopee3.jpg" rel="example4" title="On the Ohoopee as an adult">Grouped Photo 3</a></p>

4、jquery初始化代码

$(document).ready(function(){
//Examples of how to assign the ColorBox event to elements
$("a[rel='example1']").colorbox();
$("a[rel='example2']").colorbox({transition:"fade"});
$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
$("a[rel='example4']").colorbox({slideshow:true});
$(".example5").colorbox();
$(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
$(".example7").colorbox({width:"80%", height:"80%", iframe:true});
$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
$(".example9").colorbox({
onOpen:function(){ alert('onOpen: colorbox is about to open'); },
onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
});
});

OK,ColorBox就介绍到这里,希望对大家有所帮助。

原文链接

联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2