javascript - Increase top and bottom margin FancyBox v2 because of fixed navigation - Stack Overflow

admin2025-04-20  0

I'm currently working on a website which in future will be responsive. The site is primarily made up of images which in turn load into a FancyBox when clicked. v2 of FancyBox is now responsive and so re-sizes the images etc when screen size changes. As part of my design I have two fixed banners which appear at the top and bottom of the page, see image below:

By default there is a margin around the FancyBox so that it's styled nicely. However, with the fixed positioning that I've added to the banners I need to increase the top and bottom margin. I've looked through the JS source but I can't for the life of me find where I should be adding extra margin. There are all sorts of margins on the transitions etc (which I think is where I'm getting confused).

In theory I just need to add "x" amount of pixels to the margin, where x is the height of the banners. As an aside I'm not sure how I would replicate this in a responsive design, as the banners may be slightly shallower on a mobile. Adding the margin would mean there's a slight gap between the image and the banner, where currently the image goes behind the banner. See the following image for what I'd like it to look like:

I'd appreciate any thoughts/examples of where this has been done before.

Thanks in advance, Adam.

I'm currently working on a website which in future will be responsive. The site is primarily made up of images which in turn load into a FancyBox when clicked. v2 of FancyBox is now responsive and so re-sizes the images etc when screen size changes. As part of my design I have two fixed banners which appear at the top and bottom of the page, see image below:

By default there is a margin around the FancyBox so that it's styled nicely. However, with the fixed positioning that I've added to the banners I need to increase the top and bottom margin. I've looked through the JS source but I can't for the life of me find where I should be adding extra margin. There are all sorts of margins on the transitions etc (which I think is where I'm getting confused).

In theory I just need to add "x" amount of pixels to the margin, where x is the height of the banners. As an aside I'm not sure how I would replicate this in a responsive design, as the banners may be slightly shallower on a mobile. Adding the margin would mean there's a slight gap between the image and the banner, where currently the image goes behind the banner. See the following image for what I'd like it to look like:

I'd appreciate any thoughts/examples of where this has been done before.

Thanks in advance, Adam.

Share Improve this question edited Aug 24, 2013 at 18:04 Adam Holmes asked Aug 24, 2013 at 17:40 Adam HolmesAdam Holmes 1,7934 gold badges22 silver badges35 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

try the margin API option

$(".fancybox").fancybox({
    margin: [120, 60, 20, 60] // top, right, bottom, left
});

See JSFIDDLE

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745126181a286438.html

最新回复(0)