又一个绝对棒的对话框插件fancybox v1.3.4

http://www.jsfoot.com/jquery/demo/2011-07-30/fancybox/index.html

 

jquery插件:fancybox

 

Fancybox的特点如下:

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

使用方法:

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

 

1
2
<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(一些动画效果)你还需要引入以下脚本

 

 

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" />
 
 
 
以下是一个实现小图缩放效果的例子:
复制代码
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="imagetoolbar" content="no"/>
<title>FancyBox 1.3.1 | Demonstration</title>
<script type="text/javascript" src="js/jquery-1.4.min.js"></script> <!--调用jquery核心库----->
<script type="text/javascript" src="js/jquery.mousewheel-3.0.2.pack.js"></script><!--调用可用鼠标控制的库-->
<script type="text/javascript" src="js/jquery.fancybox-1.3.1.js"></script>
<script type="text/javascript" src="js/pngobject.js"></script> <!--correctly handle PNG transparency in Win IE 5.5 & 6.-->
<link rel="stylesheet" href="style/style.css" type="text/css"/>
<link rel="stylesheet" href="style/jquery.fancybox-1.3.1.css" type="text/css"/>
复制代码


 

复制代码
<script type="text/javascript">
$(document).ready(function() {
/**
运行的代码
*/

$("a[rel=example_group]").fancybox({
'transitionIn' : 'fade', //设置动画效果. 可以设置为 'elastic', 'fade' 或 'none'
'transitionOut' : 'fade', //同上
'titlePosition' : 'over', //设置标题显示的位置.可以设置成 'outside', 'inside' 或 'over'
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { //可以自定义标题的格式
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
}
});

<!-------------------------------------以下属于测试代码,不在此例子效果实现的代码内------------------------------------>
/*
* 单独设置每个图片或文件的效果
*/

$("a#example1").fancybox({
'titleShow' : true //是否显示标题
});

$("a#example2").fancybox({
'titleShow' : true,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});

$("a#example3").fancybox({
'titleShow' : true,
'transitionIn' : 'none',
'transitionOut' : 'none'
});

$("a#example4").fancybox();

$("a#example5").fancybox({
'titlePosition' : 'outside'
});

$("a#example6").fancybox({
'titlePosition' : 'outside'
});

/*
* 设置id号为various效果
*/

$("#various1").fancybox({
'titlePosition' : 'over',//标题显示的位置
'transitionIn' : 'none',
'transitionOut' : 'none'
});

$("#various2").fancybox();

$("#various3").fancybox({
'width' : '75%',
'height' : '75%',
'autoScale' : false,
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'type' : 'iframe'

});

$("#various4").fancybox({
'padding' : 0,
'autoScale' : false, //如果为true,fancybox可以自适应浏览器窗口大小
'transitionIn' : 'none',
'transitionOut' : 'none'

});
});
</script>
复制代码

 

复制代码
</head>
<body>
<div id="content">
<h4>jQuery FancyBox 实现点击小图显示大图</h4>
<p>
<a rel="example_group" href="example/4_b.jpg" title="Lorem ipsum dolor sit amet"><img alt="" src="example/4_s.jpg"/></a>

<a rel="example_group" href="example/5_b.jpg" title=""><img alt="" src="example/5_s.jpg"/></a>

<a rel="example_group" href="example/6_b.jpg" title=""><img alt="" src="example/6_s.jpg"/></a>
</p>
<p>
<a rel="example_group" href="example/7_b.jpg" title="Lorem ipsum dolor sit amet"><img alt="" src="example/7_s.jpg"/></a>

<a rel="example_group" href="example/8_b.jpg" title=""><img alt="" src="example/8_s.jpg"/></a>

<a rel="example_group" href="example/9_b.jpg" title=""><img alt="" src="example/9_s.jpg"/></a>
</p>
</div>
<div><p>&nbsp;</p></div>
</body>
</html>
复制代码

 

posted @ 2015-09-17 08:47  充实地生活着  阅读(531)  评论(0编辑  收藏  举报