FancyBox2 - Title on top AND on the bottom?

半城伤御伤魂 提交于 2019-12-02 08:44:28

You can modify the default fancybox template to add some extra HTML in. Like so:

Your HTML:

<a href='http://www.bbc.co.uk/news' class="fancybox" data-caption="caption here" title="Title here">Click</a>

Javascript:

$(".fancybox").fancybox({
    type: 'iframe',
    beforeLoad: function() {
        var caption = this.element.attr('data-caption');
        this.tpl.wrap = '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div><p>'+caption+'</p></div></div></div>'

    },

    helpers:  {
        title : {
            type : 'inside',
            position: 'top'
        }
    }
});

I've used an iFrame as an example, but this should work for any Fancybox type.

JS Fiddle here: http://jsfiddle.net/WillDonohoe/thy0om73/

Look under the tpl section of the fancybox docs for more information: http://fancyapps.com/fancybox/#docs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!