jQuery图片播放插件ColorBox使用方法
昨天給大家介紹了一款功能很強大的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就介紹到這里,希望對大家有所幫助。
原文鏈接
轉載于:https://www.cnblogs.com/sxwgf/archive/2011/10/31/2230867.html
總結
以上是生活随笔為你收集整理的jQuery图片播放插件ColorBox使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一文带你掌握监控进程技术实现
- 下一篇: SAN 光纤交换机配置zone实验