fancybox icon indicating copy to clipboard operation
fancybox copied to clipboard

height: 100vh on body element causes page to jump to top when opening fancybox

Open matthendrix opened this issue 8 years ago • 4 comments

Using this code in my website's css causes the page to jump when opening fancybox.

body { display: flex; flex-direction: column; height: 100vh; }

It appears to be caused by this rule in jquery.fancybox.css;

body.fancybox-active { overflow: hidden; }

For me, the fix was to add this to my website's css file;

body.fancybox-active { overflow: initial !important; }

Just thought' I'd mention this for anyone else having this issue.

matthendrix avatar Mar 28 '18 01:03 matthendrix

Hi,

Why do you think it is a good idea to make changes like these to the body element? I always wonder why people do crazy things and then ask - please, fix your script, it is not working on my page. Why don't you create a root element for that layout thing and let poor body element alone? 😄

Anyway, the upcoming version (you can preview it here - https://codepen.io/fancyapps/pen/VyLOJX?editors=1010) seems to work fine with these CSS rules.

fancyapps avatar Mar 31 '18 08:03 fancyapps

Why do you think it is a good idea to make changes like these to the body element?

I think we are both guilty of this ;)

Though I like your idea of creating a root element rather than using the body element. In my case, the css is for a "sticky footer".

Thanks for your help, and please keep up the great work.

matthendrix avatar Apr 01 '18 01:04 matthendrix

Hmm, sticky footer? I think it can be achieved with simpler CSS - https://getbootstrap.com/docs/4.0/examples/sticky-footer/

fancyapps avatar Apr 01 '18 13:04 fancyapps

Thanks for that, I'd like to use that simpler method, but it relies on a fixed height footer.

I had to use"vh" in my case to account for the dynamic height of the footer.

matthendrix avatar Apr 02 '18 00:04 matthendrix