the Forum

Fancybox 2 is shifting on load

Posted on September 12, 2012 by Michael Rosario
Total Posts: 33  |  Join date: 03-12-11

This occurs when an overflow: y is used anywhere on your site and the scrollbar is present. Remove the following code on jquery.fancybox.css to solve the issue:
.fancybox-lock .fancybox-overlay {
 overflow
auto;
}

.fancybox-lock {
 overflow
hidden;

Tags: There are no tags for this entry.

11 answers, add yours below

Posted on on September 17, 2012 at 3:37pm
by Malcolm

Hi, I'm running into the same issue. My body background is moved to the left ( I can see a margin-left:21px added to the body tag in firebug) when the fancy box pop-up is triggered. I close the box, the body background comes back to it's normal place.

I tried to remove the .fancybox-lock class , but still no luck ? Any other ideas what might cause this? Many thanks.

 

Posted on on September 18, 2012 at 1:59am
by Michael Rosario

hmmm. This was the issue and removing those CSS did the trick for me. The issue occurs because fancybox has it's own srollbar. Try loading fancybox on a page without a scrollbar.

If you can provide me an example, I can see whats really going on. Thanks.

 

Posted on on September 25, 2012 at 8:28am
by joris

What i did in combination with the instructions above is set the body margin-right to zero this way:

body {
margin-right: 0 !important;
}

it's a bit of a hack but this way the inline-style set by fancybox is overruled.

 

Posted on on September 28, 2012 at 7:30am
by tapas bera

Thanks you for the help!

 

Posted on on February 1, 2013 at 2:34am
by Sergey

Previous code:

body {
width: 960px;
margin: 0 auto;
}

Fixed code:

body {
width: 960px;
margin: 0 auto !important;
}


If you're using isotope filtering or similar solution you might also want to add this:

html {
overflow-y: scroll !important;
}


 

Posted on on March 20, 2013 at 12:26pm
by Dharmu

Thanks a lot!!! smile

 

Posted on on July 18, 2013 at 3:36pm
by Michael Rosario

I was able to fix this issue changing the current code from:
.fancybox-lock {
    overflow
hidden !important;
    
widthauto;
}

.fancybox-lock body {
    overflow
hidden !important;
}

.fancybox-lock-test {
    overflow
-yhidden !important;
}

.fancybox-overlay {
 position
absolute;
 
top0;
 
left0;
 
overflowhidden;
 
displaynone;
 
z-index99999998010;
 
backgroundurl('fancybox_overlay.png');
}

.fancybox-overlay-fixed {
 position
fixed;
 
bottom0;
 
right0;
}

.fancybox-lock .fancybox-overlay {
 overflow
auto;
 
overflow-yscroll;


To this:
.fancybox-lock {

}

.fancybox-lock body {

}

.fancybox-lock-test {

}

.fancybox-overlay {
 position
absolute;
 
top0;
 
left0;

 
displaynone;
 
z-index99999998010;
 
backgroundurl('fancybox_overlay.png');
}

.fancybox-overlay-fixed {
 position
fixed;
 
bottom0;
 
right0;
}

.fancybox-lock .fancybox-overlay {



 

Posted on on July 29, 2013 at 10:16am
by Shady El Gewily

Thank you Michael Rosario!! I have been searching for a solution to this problem for quite a while, but this seems to do the trick!

 

Posted on on December 20, 2013 at 5:30am
by David Sanford

Hello,
I am hiring a sizing issue, but a whacky one.
My issue is the margin margin (or padding) on the SECOND and subsequent galleries (8 total).
I am using Dreamweaver and while in live view, i do not see the issue.
It is only after i create the .ipa via phone gap do i see the issue on my iOS device.
The first gallery is fine
The second gallery begins the issue (NOTE: that gallery works fine it terms of grouping the photos, only the top margin).
Each subsequent gallery the top error margin increases to the point were the 8th gallery has a large scroll space of nearly triple the size of the image.

Any suggestions?

 

Posted on on October 25, 2014 at 5:44am
by Manas

Thanks a lot smile This solved my issue out of other 49712394871239 things posted online.

 

Posted on on January 6, 2015 at 10:57am
by Peter

Thank you Michael Rosario

 
add your answers here
comments powered by Disqus