Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to position fancybox on top

How to position the fancybox 100px from top by default it is center aligned.

I believe there is no api settings for that. Can anyone help me out in doing it on the actual script.

like image 383
Nizam Avatar asked Jul 07 '10 18:07

Nizam


People also ask

How do I know if fancybox is loaded?

Here is the code: if ($('div#fancybox-frame:empty'). length >0) { alert('it is empty'); $.

How do I open Fancybox on button click?

jQuery(document). ready(function($) { $('button'). on('click', function() { $. fancybox(); }); });


3 Answers

The solution I got working was styling the wrapper like this:

#fancybox-wrap {
  position: absolute;
  top: 100px !important;
}

Hope it helps!

like image 170
jede Avatar answered Sep 23 '22 20:09

jede


$.fancybox({
   'width'     : 620,
   'height'    : 490,
   'speedIn'    :600,
   'speedOut'   :200,
   'onComplete': function() {
      $("#fancybox-wrap").css({'top':'20px', 'bottom':'auto'});
   }
});
like image 27
ziasumo Avatar answered Sep 25 '22 20:09

ziasumo


In fancyBox 2 I use topRatio : 0, this propery move fancyBox at top, then I used jQuery().css() to put it where I want. Example:

$("#myfancy").fancybox({
    wrapCSS     : 'fancybox-custom',
    maxWidth    : 500,
    maxHeight   : 360,
    fitToView   : false,
    width       : '85%',
    height      : '95%',
    autoSize    : false,
    openEffect  : 'fade',
    openSpeed   : 'slow',
    closeEffect : 'fade',
    modal       : true,
    closeSpeed  : 'slow',
    topRatio    : 0,
    helpers         : {
        overlay     : {
            css     : {
                'background-color' : '#fff'
            }
        }
    }
}).trigger('click');
jQuery('.fancybox-wrap').css('margin-top', '120px');
like image 39
Derekthar Avatar answered Sep 25 '22 20:09

Derekthar