jQuery - Fancybox: But I don't want scrollbars!

前端 未结 24 1894
醉话见心
醉话见心 2020-12-15 17:37

I am using jQuery Fancybox for a popup registration form here

I would like the form to come up at the size of 450px by 700px but no matter what I set the height and

相关标签:
24条回答
  • 2020-12-15 17:41

    I struggled quite a bit with this, only to find the answer within the Fancybox documentation.

    As hinted above, first I thought it would have been as easy as this to disable scrolling:

    $('.fancybox').fancybox({'type': 'iframe', 'scrolling': 'no', 'width': 500})
    

    Just setting the 'scrolling' option to 'no' was not enough, though. I had to repeat the same thing in the 'iframe' option, like this:

    $('.fancybox').fancybox({
      'type': 'iframe', 
      'scrolling': 'no', 
      'width': 500, 
      'iframe': {'scrolling': 'no'}
    })
    
    0 讨论(0)
  • 2020-12-15 17:42

    I had I guess the same issue. It wasnt what the fancybox properties or CSS was, but the main css for my site.

    if you have something like

    div {overflow:auto;height:auto;} 
    

    for a inheritable/root in your site css then it will cause scroll bar issues in the fancy box. Remove and make your HTML and CSS more precise with IDs and classes

    0 讨论(0)
  • on jquery.fancybox.js, I edited this part:

    iframe : {
    
        scrolling : 'no', // i changed this from 'auto' to 'no'
        preload   : true
    },
    
    0 讨论(0)
  • 2020-12-15 17:48

    after testing every of the above tips (and still having useless scrollbars caused by some inline overflow: scroll at .fancybox-inner) and also trying a lot of other own workarounds, i got rid of the scrollbars with this solution:

        afterShow: function(){
            this.inner.css({
                overflow: 'auto' // or 'no'
            });
        }
    
    0 讨论(0)
  • 2020-12-15 17:50

    Another alternative is to change the overflow:

    body {
        overflow: hidden;
    }
    

    in your iframe's HTML.

    0 讨论(0)
  • 2020-12-15 17:54

    I have face the same problem and after times of trial and error, I found out that you can avoid scrollbars by overriding frame css class.

    You can do like this:

    iframe.fancybox-iframe {
        overflow:hidden;
    }
    

    JS configuration:

    jQuery(document).ready(function(){
        $("a.various").fancybox({
            'width'             : 'auto',
            'height'            : 'auto',
            'autoScale'         : false,
            'autoDimensions'    : false,
            'scrolling'         : 'no',
            'transitionIn'      : 'none',
            'transitionOut'     : 'none',
            'type'              : 'iframe'  
        }); 
    });
    

    Note: Your fancybox box type must be an iframe for this to take effect.

    0 讨论(0)
提交回复
热议问题