FancyBox.js基于JQuery图集弹层插件用法

FancyBox是一款基于 jquery 开发的类 Lightbox 插件。支持对放大的图片添加阴影效果,对于一组相关的图片添加导航操作按纽,该 lightbox 除了能够展示图片之外,还可以展示 iframed 内容, 通过 css 自定义外观。
相对与 Lightbox 而言,阴影效果更好。但是比 Lightbox 绚丽。
使用很是简单,可以参照 Lightbox,修改添加代码。
在这里插入图片描述

示例代码:

$(document).ready(function() { 
	/* This is basic - uses default settings */ 
	$("a#single_image").fancybox(); 
	/* Using custom settings */ 
	$("a#inline").fancybox({ 'hideOnContentClick': true }); 
	$("a.group").fancybox({ 
		'zoomSpeedIn': 300, 
		'zoomSpeedOut': 300, 
		'overlayShow': false 
	}); 
});

快速使用:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<link href="/path/to/jquery.fancybox.min.css" rel="stylesheet" />
<script src="/path/to/jquery.fancybox.min.js"></script>

HTML创建链接

<a data-fancybox="gallery" href="big_1.jpg">
  <img src="small_1.jpg" />
</a>

<a data-fancybox="gallery" href="big_2.jpg">
  <img src="small_2.jpg" />
</a>

<!-- FancyBox.js演示:uihtm.com/preview/19516.html -->
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天天打码

打赏买瓶护发素吧!~~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值