最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Width and height issue with fancybox - Stack Overflow

programmeradmin3浏览0评论

When I've added this code no setting on width and height works

jQuery(document).ready(function() {
  $('a.iframe').fancybox(); 
});

What are the options to get around it?

When I've added this code no setting on width and height works

jQuery(document).ready(function() {
  $('a.iframe').fancybox(); 
});

What are the options to get around it?

Share Improve this question edited Mar 26, 2013 at 3:37 Nima Parsi asked Sep 9, 2011 at 18:21 Nima ParsiNima Parsi 2,1102 gold badges23 silver badges33 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 9

Take a look at the documentation here: http://fancybox.net/api

You're using inline content, so make sure that you're setting the autoDimensions option to false along with the width and height settings.

UPDATE: I tested the following solution successfully:

    $('a.fbtag').fancybox({
        autoDimensions: false,
        height: 300,
        width: 400
    }); 

This assumes that the class name of the link you're opening is 'fbtag'.

Fancy Box width and Height always varies with the media type.

If we provide 5 * 5 pixel image - Fancy Box will show up with dimensions of Image Dimensions.

To counter the effect of media dimensions and define the default width & height for Fancy Box

Try this:

$.fancybox.open(collection.toJSON(), {
   afterShow :function(){},
   maxHeight    : 600,
   minWidth : 500           
}); 

FancyBox width will be minimum - 500 pixels.

FancyBox Height will be proportional to the FancyBox data with maximum Height of 600 pixels.

For example

$.fancybox({
    'content':"This will be the content of the fancybox",
    'width':'500',
    'autoDimensions':false,
    'type':'iframe',
    'autoSize':false
});
$(document).ready(function() {
    $(".fancy-ajax").fancybox({
        type:           'ajax',
        autoDimensions: false,
        'autoSize':     false,
        'height':       'auto'
    });
});

The above codes worked for me. However, I was designing in Twitter Bootstrap.

you can do this two way

With iframe

   $(document).ready(function () {
        $(".fancybox").fancybox({
            width:600,
            height:400,
            type: 'iframe',
            href  : 'url_here'
       });
     })

Without iframe

 $(document).ready(function () {
    $(".fancybox").fancybox({
        width:600,
        height:400,
        autoDimensions: false,
   });
 })
发布评论

评论列表(0)

  1. 暂无评论