views:

65

answers:

2

I have my site's main content which is centrally positioned (see div#wrapper), as it's width is 800px. position absolute, left 50% and margin-left is -400px. works perfect .

my lightbox however (click on Client or Guest tab), is not positioning centrally. I've looked at Chrome Developer Tools and Firebug, and can't see anything wrong with the numbers. And i don't think it's an optical illusion lol.

The lightbox is too far to the right. and the one for Price Match Promise (at the bottom of the page) comes up and is too far down. The left, top, margin-left and margin-top are set dynamically by jQuery, but the evaluated numbers are looking correct. body is 1280px wide on my resolution and so is document, so margin-left becomes -640px. seemingly correct.

any ideas?

http://www.mymediaventure.com/about.php

A: 

If you want to show the popup always center of the screen this is one of the best examples.. http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

the above example works if you don't have vertical scroll bar , if your page has more data and with vertical bar use other property to get the complete height intead of client height...of the the browser

the above example has logic to calculate and set the popup in the center. I am doing something similar in one of my proejcts , please ask more if this doesn't answer your question

gov
the thing that i notice about that example is that even though their method of centering is different to mine, it calculates exactly the same figure. and also, despite my lightbox width and height set in the CSS, i am unable (for a reason i am unsure) to get these with the .width() and .height() functions. I am using the .css on both of these and parsing integers from the strings they return. i doubt this is the issue though.
Alex B
A: 

always include YUI reset, and specify the DOCTYPE: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; These rules are of my own.
And I think the problem comes from your position: relative and negative margin-left because, and your width is 800px and the content needs more!!, try to set overflow: hidden for div#wrapper and see there is some pixels is hidden which means that something is wrong!!

Something that popped up into my eyes which is totally wrong!

#wrapper div#content {
    border-width:5px 1px 1px;
    left:50%;
    margin-left:-400px;
    position:relative;
    width:800px;
}


div#wrapper {
    left:50%;
    margin-left:-400px;
    position:absolute;
    width:800px;
}

Why reposition the div#content!! and why is the width exceeding 800px? remember final width is 802px because left and right borders are 1px.

You have a lot of bad practice things my friend, try to code carefully next time :)!

Omar Dolaimy
ok thanks. i have cleaned it up a little. it still doesn't explain why it won't center. it looks at least 20px too far to the right. and it is too low.
Alex B