Center popup div of diffrent size…
Posted: 08 August 2009 03:05 PM   [ Ignore ]
Newbie
Rank
Total Posts:  2
Joined  2009-04-09

Good day to you all,
    I working on a directory list images and I’m having problem displaying the popup div , when an image is clicked, in the middle of the window.

My main problem is that it’s not all the images that as the same size.

Here anexample of my images linked to my popup up.

<?PHP
// add it to portrait list
    
$portrait .= "<a onmouseover=this.style.cursor=\"pointer\" ' ' onclick=\"document.getElementById('".$value."').style.display 'block' \" ><img src=\"".$directory."/".$value."\" width=\"50px\" class=\"imag\"></a>\n"
    
$portrait .= "<div id=\"".$value."\"   style=\"displaynone;  positionabsolute;  margin-left:automargin-top:auto;  padding10pxbackground-color#ffffff; text-align: justify; font-size: 12px;\">";
    
$portrait .= "<img src=\"".$directory."/".$value."\"   name=\"".$value."\"/><br />".$value."<br/><div style=\"color:#000000; background-color:#ffffff; font-size:14px; text-align:center;\" onmouseover=\"this.style.backgroundColor='#cccccc'; this.style.cursor='pointer';\" style='font-size: 12px; ' onfocus='this.blur();' onmouseout=\"this.style.backgroundColor='#FFFFFF';\" onclick=\"document.getElementById('".$value."').style.display = 'none' \" ><b>Fermer</b></div></div>";
    
}
//...
?> 

Thanks!

Profile
 
 
Posted: 13 August 2009 06:20 AM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  19
Joined  2009-07-27

The best way to do this would be to use a Javascript code. However, it is very difficult for me to read your code because of all the PHP stuff you have in there. It appears that you have a little Javascript knowledge, the best way to always center it would be to tell JS to get the inner window height, (There are a couple ways to do this, depending on the browser so you use both methods) then you do something like this.


Search engine optimization

Profile