jQuery Fancybox插件使用参数详解

Fancybox的特点如下:
- 可以支持图片、html文本、flash动画、iframe以及ajax的支持
- 可以自定义播放器的CSS样式
- 可以以组的形式进行播放
- 如果将鼠标滚动插件(mouse wheel plugin)包含进来的话Fancybox还能支持鼠标滚轮滚动来翻阅图片
- Fancybox播放器支持投影,更有立体的感觉
Fancybox使用方法:
1、引入jquery核心库和Fancybox插件库
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
可选 - 如果需要用到fancy transition(一些动画效果)你还需要引入以下脚本
<script type="text/javascript" src="/fancybox/jquery.easing-1.4.pack.js"></script>
可选 - 如果需要支持鼠标滚轮滚动效果你还需要引入以下脚本
<script type="text/javascript" src="/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
2、添加样式表文件
<link rel="stylesheet" href="/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen">
3、在页面上创建链接元素
A、图片元素
<a id="single_image" href="image_big.jpg"><img src="data:image_small.jpg" kesrc="data:image_small.jpg" alt=""></a>
B、普通文本
<a id="inline" href="#data" kesrc="#data">This shows content of element who has id="data"</a> <div style="display: none;">
<div id="data">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</div>
C、Iframe
<a href="http://www.example?iframe">This goes to iframe</a> 或者 <a class="iframe" href="http://www.example">This goes to iframe</a>
D、Ajax
<a href="http://www.example/data.php">This takes content using ajax</a>
如果你要显示描述信息,可以在链接上加上title,将描述信息放到title中。
4、最终的jquery初始化代码
$(document).ready(function() {
/* 最基本的,使用了默认配置 */
$("a#single_image").fancybox();
/* 使用了自定义配置 */
$("a#inline").fancybox({
'hideOnContentClick': true
});
/* 一下配置支持组播放 */
$("a.group").fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false
});
});
用rel标签来创建相册
<a class="grouped_elements" rel="group1" href="image_big_1.jpg"><img src="data:image_small_1.jpg" alt=""></a>
<a class="grouped_elements" rel="group1" href="image_big_2.jpg"><img src="data:image_small_2.jpg" alt=""></a> <a class="grouped_elements" rel="group2" href="image_big_3.jpg"><img src="data:image_small_3.jpg" alt=""></a>
<a class="grouped_elements" rel="group2" href="image_big_4.jpg"><img src="data:image_small_4.jpg" alt=""></a> $("a.grouped_elements").fancybox();
Fancybox的API和配置选项说明
Fancybox的API和配置选项说明
| 属性名 | 默认值 | 简要说明 |
|---|---|---|
| padding | 10 | 浏览框内边距,和css中的padding一个意思 |
| margin | 20 | 浏览框外边距,和css中的margin一个意思 |
| opacity | false | 如果为true,则fancybox在动画改变的时候透明度可以跟着改变 |
| modal | false | 如果为true,则'overlayShow' 会被设成 'true' , 'hideOnOverlayClick', 'hideOnContentClick', 'enableEscapeButton', 'showCloseButton' 会被设成 'false' |
| cyclic | false | 如果为true,相册会循环播放 |
| scrolling | 'auto' | 设置overflow的值来创建或隐藏滚动条,可以设置成 'auto', 'yes', or 'no' |
| width | 560 | 设置iframe和swf的宽度,如果 'autoDimensions'为 'false',这也可以设置普通文本的宽度 |
| height | 340 | 设置iframe和swf的高度,如果 'autoDimensions'为 'false',这也可以设置普通文本的高度 |
| autoScale | true | 如果为true,fancybox可以自适应浏览器窗口大小 |
| autoDimensions | true | 在内联文本和ajax中,设置是否动态调整元素的尺寸,如果为true,请确保你已经为元素设置了尺寸大小 |
| centerOnScroll | false | 如果为true,当你滚动滚动条时,fancybox将会一直停留在浏览器中心 |
| ajax | { } | 和jquery的ajax调用选项一样 注意: 'error' and 'success' 这两个回调事件会被fancybox重写 |
| swf | {wmode: 'transparent'} | swf的设置选项 |
| hideOnOverlayClick | true | 如果为true则点击遮罩层关闭fancybox |
| hideOnContentClick | false | 如果为true则点击播放内容关闭fancybox |
| overlayShow | true | 如果为true,则显示遮罩层 |
| overlayOpacity | 0.3 | 遮罩层的透明度(范围0-1) |
| overlayColor | '#666' | 遮罩层的背景颜色 |
| titleShow | true | 如果为true,则显示标题 |
| titlePosition | 'outside' | 设置标题显示的位置.可以设置成 'outside', 'inside' 或 'over' |
| titleFormat | null | 可以自定义标题的格式 |
| transitionIn, transitionOut | 'fade' | 设置动画效果. 可以设置为 'elastic', 'fade' 或 'none' |
| speedIn, speedOut | 300 | fade 和 elastic 动画切换的时间间隔, 以毫秒为单位 |
| changeSpeed | 300 | 切换时fancybox尺寸的变化时间间隔(即变化的速度),以毫秒为单位 |
| changeFade | 'fast' | 切换时内容淡入淡出的时间间隔(即变化的速度) |
| easingIn, easingOut | 'swing' | 为 elastic 动画使用 Easing |
| showCloseButton | true | 如果为true,则显示关闭按钮 |
| showNavArrows | true | 如果为true,则显示上一张下一张导航箭头 |
| enableEscapeButton | true | 如果为true,则启用ESC来关闭fancybox |
| onStart | null | 回调函数,加载内容是触发 |
| onCancel | null | 回调函数,取消加载内容后触发 |
| onComplete | null | 回调函数,加载内容完成后触发 |
| onCleanup | null | 回调函数,关闭fancybox前触发 |
| onClosed | null | 回调函数,关闭fancybox后触发 |
jQuery Fancybox插件使用参数详解的更多相关文章
- 【Jquery系列】JqGrid参数详解
1 概述 本篇文章主要与大家分享JqGrid插件参数问题. 2 参数详解 2.1 初始化参数 2.2 ColModel参数 3 json数据 jqGrid可支持的数据类型:xml.jso ...
- jquery.dataTables插件使用例子详解
DataTables是一个jQuery的表格插件.这是一个高度灵活的工具,依据的基础逐步增强,这将增加先进的互动控制,支持任何HTML表格 效果图 代码 <!doctype html> & ...
- jQuery延迟加载插件(Lazy Load)详解
最 新版本的Lazy Load并不能替代你的网页.即便你使用JavaScript移除了图片的src属性,有些现代的浏览器仍然会加载图片.现在你必须修改你的html代 码,使用占位图片作为img标签的s ...
- JQuery中$.ajax()方法参数详解
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- JQuery中$.ajax()方法参数详解 及 async属性说明
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- JQuery中$.ajax()方法参数详解(转载)
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- 转:JQuery中$.ajax()方法参数详解
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- (转)JQuery中$.ajax()方法参数详解
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...
- Jquery中$.ajax()方法参数详解(转)
转自:http://blog.sina.com.cn/doctor830619 url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数, ...
随机推荐
- iframe脸面的页面和父页面之间的交互方法
1.iframe父页面修改iframe中的页面的信息 var obj = document.getElementById("iframeId").contentWindow; ...
- jQuery 遍历 (each、map)
jQuery 遍历,意为“移动”,用于根据其相对于其他元素的关系来“查找”(或选取)HTML 元素.以某项选择开始,并沿着这个选择移动,直到抵达您期望的元素为止. jQuery 遍历函数 jQuery ...
- PLSQL 用的让自己更舒心点!
每天开发时候 ,有时候会疲劳! 改下你的PLSQL 字体吧!
- Lucene索引数计算
Elasticsearch默认在创建索引结束时得到5个分片及1个副本: 分片是有0-n个副本,“5个分片及1个副本”即“5个分片及5个相应分片副本”:共10个Lucene索引 副本数:指的是“单个分片 ...
- redo binlog
w https://dev.mysql.com/doc/refman/5.7/en/innodb-redo-log.html https://dev.mysql.com/doc/refman/5.7/ ...
- String研究
=======================String=================================== String里的==和equalsJava String “equal ...
- Java语言实现简单FTP软件------>FTP软件主界面的实现(四)
首先看一下该软件的整体代码框架 1.首先介绍程序的主入口FTPMain.java,采用了一个漂亮的外观风格 package com.oyp.ftp; im ...
- 我的Java开发学习之旅------>Eclipse 项目有红感叹号解决之道
今天一个读者问我关于Android通过调用Webservice实现天气预报这篇文章的源码下载后出现的错误 Could not find class 'org.ksoap2.transport.Http ...
- linux安装jdk_1.8
转载自http://blog.csdn.net/ldl22847/article/details/7605650 1.下载jdk的rpm安装包,这里以jdk-8u141-linux-x64.rpm为例 ...
- 画图-drawpoint and drawpath
版权声明:本文因海牛宝宝童鞋才疏学浅,可能晦涩难懂,但也是呕心沥血之作,麻烦转载的时候留个申明. https://blog.csdn.net/u012321815/article/details/26 ...