How to replace default controls with custom buttons in Fancybox 2.1.5?

跟風遠走 提交于 2019-11-27 07:56:27

问题


In Fancybox 2.1.5 I want to replace the default controls with my custom buttons (new preloader + close/next/prev buttons on sprite).

I'm not sure how to adjust the css code properly. I tried to modify the CSS as follows, but there's something wrong, the 'next' icon shows up in the top right corner instead of the 'close' button.

You can see my code on this gist.


回答1:


No need to mess with the original CSS file, use the tpl API option instead like

$(".fancybox").fancybox({
    tpl: {
        closeBtn: '<a title="Close" class="fancybox-item fancybox-close myClose" href="javascript:;"></a>'
    }
});

Notice that I added the class myClose so I can set its own specific CSS properties, background image, etc. like

.myClose {
    height: 50px;
    width: 50px;
    background: #ff0000;
}

See JSFIDDLE just as an example.

Do the same for the prev/next icons. Check the API documentation (search for tpl)



来源:https://stackoverflow.com/questions/18551391/how-to-replace-default-controls-with-custom-buttons-in-fancybox-2-1-5

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