March 4, 2012

Opening a fancyBox with a certain aspect ratio

Question by smares

Does anyone know how I can open a resizable fancyBox with a certain aspect ratio (for example 16:9)?

Answer by Adam Prax

There isn’t a native way of easily resizing Fancybox. You can do some simple math with screen.height to open a Fancybox in a particular aspect ratio relative to the current screen resolution.

height = screen.height/4;

$("#test").fancybox({
           'width' : 16/9. * height,
           'height' : height,
           'autoDimensions' : false
      }); 
});

Answer by Starx

AFAIK, Fancybox right now, does not support this. However, You can control the dimension of fancy box size

("#yourbox").fancybox({
    'width'             : 680,
    'height'             495,
    'showCloseButton'   : false,
    'titlePosition'     : 'inside',
    'titleFormat'       : formatTitle
});

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!