开发者

Keep Colorbox always centered on scroll

开发者 https://www.devze.com 2023-01-27 12:24 出处:网络
When using thickbox if a user scrolled vertically the thickbox would always stay centered. However with colorbox if they scroll they lose site of the colorbox and just see a grayed out background. How

When using thickbox if a user scrolled vertically the thickbox would always stay centered. However with colorbox if they scroll they lose site of the colorbox and just see a grayed out background. How can I update colorbox to have the same functionality where it maintains position on the screen regardless of user scrolling.

http://colorpowered.com/colorbox/core/example开发者_JAVA技巧1/index.html http://jquery.com/demo/thickbox/

resize your window to have a vertical scrollbar and scroll and you can see the difference.

Thanks


I may be a bit late, but FYI you can simply use the "fixed" option in your colorbox declaration. This option is "false" by default. If you set it to "true" you get the result you want:

$('#my_box').colorbox({
    fixed: true
 });


The difference is that thickbox uses the css position:fixed to align the box, whereas colorbox uses a relative position. In the colorbox.css file try changing the line "#colorbox{}" to "#colorbox{position:fixed}" I tested it in Firebug and that seems to fix it.

The position fixed CSS won't work in IE6.

0

精彩评论

暂无评论...
验证码 换一张
取 消