惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
N
Netflix TechBlog - Medium
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 聂微东
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
S
Schneier on Security
T
Threat Research - Cisco Blogs
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Hacker News
The Hacker News
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
T
Tenable Blog
S
Secure Thoughts
T
Threatpost
V2EX - 技术
V2EX - 技术
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
Engineering at Meta
Engineering at Meta
小众软件
小众软件
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
Y
Y Combinator Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
P
Privacy International News Feed
H
Heimdal Security Blog
量子位
B
Blog

博客园 - pot

在框架中(IFRAME/FRAMESET)传递COOKIE的解决方案[转] C#生成缩略图代码 数据抓取的一个类,包含一些常用的方法 抓取AJAX网页的方法-Firefox组件,C#集成 C#编号的ActiveX控件采用CAB的布署方式实例 C#编写ActiveX控件实例(包括命令和事件) PdfAcroViewer C#代码登录活动目录 用XML反序列化快速完成ASP.NET配置文件 - pot - 博客园 android Activity类的使用 Android中的Intent详细讲解 Android模拟器常用使用,和基本功能使用 ZPL II 命令参考 正则表达式语法 - pot - 博客园 《C#异常处理》 C#中接口的作用 The RSA key container could not be opened - pot ASP.NET 页面事件执行顺序 关于object sender,EventArgs e 的一些解释
jQuery图片播放插件Fancybox使用方法
pot · 2012-04-13 · via 博客园 - pot

今天给大家介绍的jquery图片播放插件叫Fancybox,相比LightBox来说,Fancybox相对庞大点,配置也更丰富一些,相信你会喜欢的。

Fancybox的项目主页地址:

http://fancybox.net/

Fancybox的特点如下:


  • 可以支持图片、html文本、flash动画、iframe以及ajax的支持
  • 可以自定义播放器的CSS样式
  • 可以以组的形式进行播放
  • 如果将鼠标滚动插件(mouse wheel plugin)包含进来的话Fancybox还能支持鼠标滚轮滚动来翻阅图片
  • Fancybox播放器支持投影,更有立体的感觉

Fancybox使用方法:

1、引入jquery核心库和Fancybox插件库

可选 - 如果需要用到fancy transition(一些动画效果)你还需要引入以下脚本

1
<script type="text/javascript" src="/fancybox/jquery.easing-1.4.pack.js"></script>

可选 - 如果需要支持鼠标滚轮滚动效果你还需要引入以下脚本

1
<script type="text/javascript" src="/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>

2、添加样式表文件

1
<link rel="stylesheet" href="/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />

3、在页面上创建链接元素
A、图片元素

1
<a id="single_image" href="image_big.jpg"><img src="image_small.jpg" alt=""/></a>

B、普通文本

1
2
3
4
5
<a id="inline" href="#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

D、Ajax

如果你要显示描述信息,可以在链接上加上title,将描述信息放到title中。
4、最终的jquery初始化代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$(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标签来创建相册

1
2
3
4
5
6
7
<a class="grouped_elements" rel="group1" href="image_big_1.jpg"><img src="image_small_1.jpg" alt=""/></a>
<a class="grouped_elements" rel="group1" href="image_big_2.jpg"><img src="image_small_2.jpg" alt=""/></a>      
  
<a class="grouped_elements" rel="group2" href="image_big_3.jpg"><img src="image_small_3.jpg" alt=""/></a>  
<a class="grouped_elements" rel="group2" href="image_big_4.jpg"><img src="image_small_4.jpg" alt=""/></a>  
  
$("a.grouped_elements").fancybox();

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后触发

好了,这款fancybox图片播放插件就介绍到这里。