FancyBox 2 Background Issue

前端 未结 2 830
你的背包
你的背包 2020-12-07 05:49

I\'m trying to use fancybox (http://fancyapps.com/fancybox/) to show an image automatically on my page, but the background (greyed-out) portion is not working. Any ideas?

2条回答
  •  心在旅途
    2020-12-07 06:18

    The issue is that if you open fancybox programmatically BEFORE the DOM is ready, somehow the overlay is not appended to the body element.

    This :

    
    

    ... will trigger fancybox on page load WITHOUT an overlay (a manual click to the link thereafter won't reproduce the issue though)

    You should wrap at least the .trigger() method inside the .ready() method like :

    
    

    You can leave the fancybox init outside the .ready() method IF you are initializing it at the bottom of the page otherwise you should also move it.

提交回复
热议问题