Bonjour,
Mon probléme est le suivant, je n'arrive pas a center en hauteur un div (position:absolute; // au niveau du BODY).
Si je ne peux pas scroller, j'ai aucun soucis, celui est parfaitement centré ! Mais si je scrool (en hauteur), il sera centré comme si je n'avais pas scrollé.
Donc, en gros, comment connaitre la position du document étant scroller.
L'object :<div id="contact-error">
<p style="padding-bottom:10px;">Vous n'avez pas saisie tous les champs du formulaire.</p>
<p><a href="#" onClick="close_error('contact-error');">Fermer</a></p>
</div>
Fonction de positionnement :
function open_error(type) { // type = id de l'objet à pos
if (document.height < screen.heigh) var h=screen.heigh;
else var h=document.height;
document.getElementById('content-error').style.height=h;
document.getElementById('content-error').style.display='block';
getWindow();
var posLeft=(pageWidth-400)/2;
var posTop=(pageHeight-50)/2;
document.getElementById(type).style.marginLeft=(posLeft<0) ? 0+"px" : posLeft+"px";
document.getElementById(type).style.marginTop=(posTop<0) ? 0+"px" : posTop+"px";
document.getElementById(type).style.display='block';
}
function getWindow() {
pageWidth = window.innerWidth;
pageWidth = (pageWidth) ? pageWidth : document.documentElement.clientWidth;
pageWidth = (pageWidth) ? pageWidth : document.body.clientWidth;
pageHeight = window.innerHeight;
pageHeight = (pageHeight) ? pageHeight : document.documentElement.clientHeight;
pageHeight = (pageHeight) ? pageHeight : document.body.clientHeight;
}
[ Lien ]