如何将fancybox定位在顶部

Niz*_*zam 16 jquery fancybox

如何将fancybox 100px从顶部定位到默认情况下它是居中对齐的.

我相信没有api设置.任何人都可以帮助我在实际的脚本上做这件事.

jed*_*ede 21

我工作的解决方案是像这样设计包装器:

#fancybox-wrap {
  position: absolute;
  top: 100px !important;
}
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你!


小智 13

$.fancybox({
   'width'     : 620,
   'height'    : 490,
   'speedIn'    :600,
   'speedOut'   :200,
   'onComplete': function() {
      $("#fancybox-wrap").css({'top':'20px', 'bottom':'auto'});
   }
});
Run Code Online (Sandbox Code Playgroud)

  • 它不能正常工作.它将图像移动到顶部,但在转换后. (5认同)

Jav*_*ier 5

在fancyBox 2我使用topRatio : 0,这个在顶部移动fancyBox,然后我曾经jQuery().css()把它放在我想要的地方.例:

$("#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');
Run Code Online (Sandbox Code Playgroud)