PDA

View Full Version : Lightbox 2.03a Help - positioning



ReeceProBen
05-27-2011, 10:37 AM
1) Script Title: Lightbox 2.03a

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm

3) Describe problem: Positioning!

Apologies if this problem is already somewhere in the forum.
I'm sure there is a real simple fix to this, but I can't work it out!

How do you reduce the margin at the top of the lightbox when it appears, so it is closer to the top of the browser window?

This is a great script, use it loads!

Thanks for any help

jscheuer1
05-27-2011, 03:26 PM
At the beginning of the lightbox.css file add the highlighted as shown:


#lightbox{
position: absolute;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
line-height: 0;
margin-top: -25px;
}

However, be aware that the distance from the top is determined by the user's window's visible area's height divided by 2 minus the height of the lightbox (varies with image height and description (if any) length) divided by 2. It's centered vertically. If the user's window is too short, adding a negative margin can put portions of the top of the lightbox outside the viewable area. For this reason I would say that -50px is the limit.

I would even say that living with it 'as is' might be a good idea. -10px or -20px should be fine in most cases. Do you have any really tall images that have trouble fitting on your monitor with the default values? If so, consider resizing them (making them proportionally shorter in an image editing program) rather than moving the lightbox.

Luys
05-29-2011, 05:01 PM
Hi all!

I'm not sure if I'm wrong, but I remember when I was trying something similar to the above and I modified a value (the 10?) within lightbox.js file and the result was what I desired. I think humbly that this is a relative best solution... :)


// calculate top offset for the lightbox and display
var arrayPageScroll = getPageScroll();
var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);

Luys