Fancybox 2 Dynamic Width Based on Content Size

前端 未结 3 706
孤街浪徒
孤街浪徒 2021-01-22 21:54

I\'ve got an IFrame being opened via Fancybox 2 that plays a video:

HTML:



        
3条回答
  •  悲哀的现实
    2021-01-22 22:38

    Looking at your intro-file.cfm file makes things clearer.

    If your code inside the file is working fine, I think that you could get the dimensions from the preview_wrapper container.

    Just two questions:

    • if you are using $ ... in $('.loading-video').slideUp() for instance, shouldn't you be including the jquery.js file inside your intro-file.cfm file?
    • is this double ## before the selector in $('##preview_wrapper').width() correct?

    Assuming that everything is working fine, then try including in your fancybox script:

      scrolling: "no", // optional to avoid scrollbars inside fancybox
      beforeShow: function(){
       this.width = $('.fancybox-iframe').contents().find('#preview_wrapper').width();
       this.height = $('.fancybox-iframe').contents().find('#preview_wrapper').height();
      }
    

    ... to get the dimensions from the player's wrapper.

提交回复
热议问题