2012-07-06 99 views
3

我有一个简单的图片库,用户可以点击缩略图图片,Fancybox将打开全尺寸的图片。太好了,它可以工作。现在,我想添加一些自定义HTML,以便将图像包含在底部具有标题的包装中,并将照片注释到照片右侧(认为是脸书)。我该怎么做呢?我一直在努力研究如何做到这一点,我所能做的就是让原始照片与Fancybox打开。这里是我使用的代码:如何将自定义HTML添加到Fancybox?

$(document).ready(function() { 
    $(".fancybox-button").fancybox({ 
     padding  : 0, 
     prevEffect : 'none', 
     nextEffect : 'none', 
     closeBtn : false, 
     helpers : { 
      title  : { type : 'inside' }, 
      buttons  : {} 
     } 
    }); 
}); 

我正在寻找这样的事情(注意最后一行):

$(document).ready(function() { 
    $(".fancybox-button").fancybox({ 
     padding  : 0, 
     prevEffect : 'none', 
     nextEffect : 'none', 
     closeBtn : false, 
     helpers : { 
      title  : { type : 'inside' }, 
      buttons  : {}, 
      html : {'<div>my custom html</div>'} 
     } 
    }); 
}); 

我将如何做到这一点?

+0

看到[这] (http://fancybox.net/blog)fancybox网站上的页面。在那里你会找到你需要的例子。 – madfriend 2012-07-06 05:27:32

+0

@madfriend:错误的链接,他正在使用版本2(我猜你知道有两个不同的网站,为v1.x和v2.x,是吗?) – JFK 2012-07-06 05:59:13

+0

ooops,[链接](http:// fancyapps。 com/fancybox /#examples) – madfriend 2012-07-06 12:07:14

回答

3

看这个demo

你在找这样的事情?

+0

是的!我试图理解你做了什么。我想我明白了吗? – 2012-07-06 05:29:29

+1

只需隐藏您想要在精美盒子中展示的div。使用等于div的锚标记的href和onclick调用锚标记上的花哨框函数。就这样。 – Kishore 2012-07-06 05:34:39

13

要自定义HTML弹出窗口上的fancybox 2:

$.fancybox({ content: '<div>my custom html</div>' });