Jquery#fancyBox

fancyBox:


什么是fancyBox?


fancyBox是一个用来显示图像,html内容和多媒体的工具,其特征是这些元素漂浮在页面之上。

fancyBox构建在jQuery框架之上。


怎么使用?


1.首先,确保你使用的是有效的DOCTYPE.否则FancyBox将不能正常工作.


2.包含必需的JavaScript文件

(推荐从CDN(Content Delivery Network)加载jQuery)

<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>

jQuery库下载:http://code.jquery.com/jquery-1.8.3.min.js

fancyBox库下载:https://github.com/fancyapps/fancyBox/zipball/v2.1.3

3.添加图片超链接:

<a id="single_1" href="" title="">
	<img src="" alt="" />
</a>

超链接的href属性和图片的src属性一样,都是需要显示图片的路径。fancyBox需要id属性来指定位置。


4.调用fancyBox库函数

$(document).ready(function() {
	$(".single_1").fancybox();
});

5.看下效果:



推荐学习网站:http://fancyapps.com/fancybox/       http://fancybox.net/home

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
How to use 1. Setup Include nessesary JS files (FancyBox uses pngFix to fix IE png transparency). --------------------------- /* required */ <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.fancybox.js"></script> /* optional */ <script type="text/javascript" src="js/jquery.pngFix.js"></script> <script type="text/javascript" src="js/jquery.metadata.js"></script> -------------------------------------------- Include FancyBox CSS file. Dont forget to change image paths. -------------------------------------------- <link rel="stylesheet" href="css/fancybox.css" type="text/css" media="screen"> -------------------------------------------- 2. Add your images Add images and wrap them with a link to the zoomed version -------------------------------------------- <a href="image_big.jpg"><img src="image_small.jpg" alt=""/></a> -------------------------------------------- Optional: Use the title attribute if you want to show a caption Optional: Use the rel attribute to group images 3. Use the plugin Sample examples: -------------------------------------------- $(document).ready(function() { $("p#test1 a").fancybox(); $("p#test2 a").fancybox({ 'hideOnContentClick': true }); $("p#test3 a").fancybox({ 'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': true }); }); ------------------------------------------- Available options hideOnContentClick Hides FancyBox when cliked on zoomed item (false by default) zoomSpeedIn Speed in miliseconds of the zooming-in animation (no animation if 0) zoomSpeedOut Speed in miliseconds of the zooming-out animation (no animation if 0) frameWidth Default width for iframed and inline content frameHeight Default height for iframed and inline content overlayShow If true, shows the overlay (false by default) overlayOpacity Opacity of overlay (from 0 to 1) itemLoadCallback Custom function to get group items (see example on this page source) Comments

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值