views:

848

answers:

6

hi,

I working with jquery colorbox. When the page content is big and colorbox is opened. Then the color box scrolled along with the page content. I want the colorbox need to be fixed even the background content scrolls.

Please help me out to fix this issue.

+1  A: 

try this. change the colorbox.css the first css rule :

from

#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}

to

#colorbox, #cboxOverlay {position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}
#cboxWrapper { position:fixed; margin:0 auto; z-index:9999; overflow:hidden;}
Puaka
in this case, the wrapper is not position center and middle for the width and height respectively.
itsoft3g
+1  A: 

Puaka i am changing a little thing, which make it works awesome. It aligns center perfectly.

Change the colorbox.css

from

#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}

to

#colorbox, #cboxOverlay{position:fixed; top:0; left:0; z-index:9999; overflow:hidden;}
#cboxWrapper{}

colorbox is perfectly aligned.

itsoft3g
A: 

puaka method only worked if I was scrolled all the way to the top. else the box would appear lower down.

i devised another method.

$("#btn").colorbox({width:"90%", height:"90%", iframe:true, scrolling:false, onOpen:function() { $("body").css("overflow", "hidden"); }, onClosed:function() { $("body").css("overflow", "auto"); }});

onOpen remove the body's scrollbar onClosed replace the scrollbar

PK
A: 

This one works even better for me:

#colorbox, #cboxOverlay{position:fixed; top:0; left:0; z-index:9999; overflow:hidden;}
#cboxWrapper{position:fixed;}
bradaric
A: 

based on bradaric idea, you might need to change

        posTop = Math.max(winHeight - settings.h - loadedHeight - interfaceHeight,0)/2 + $window.scrollTop(),
        posLeft = Math.max(document.documentElement.clientWidth - settings.w - loadedWidth - interfaceWidth,0)/2 + $window.scrollLeft();

to

        posTop = Math.max(winHeight - settings.h - loadedHeight - interfaceHeight,0)/2,
        posLeft = Math.max(document.documentElement.clientWidth - settings.w - loadedWidth - interfaceWidth,0)/2;

in the position function. (Works for me)

azatoth
A: 

the css fix doesn't work for IE quirks mode.. ideas any body ?

thanks, David

David