Hi to all, I'm sorry to bother you again,but I have the following problem, I have the following DIV, that I need to position in the center of the page, I have the following code, but you can see the div is not exactly center, space I have from the top is not the same I have in the bottom, the space I have from bot side is the same.
I was wandering also if I can do this dynamically, meaning the div will receive the width and height in run time, and them I will send the values to my method "centerObj" (How I can get the height and width of the div element.
<html>
<head>
<script>
function centerObj()
{
var height = 200;
var width = 400;
height = height/2;
height = String("-" + height + "px");
width = width/2;
width = String("-" + width + "px");
var container = document.getElementById('MyDiv');
container.style.marginTop;
container.style.position="absolute";
container.style.top = "50%";
container.style.left="50%";
container.style.marginTop=height;/* half elements height*/
container.style.marginLeft=width;/* half elements width*/
}
</script>
</head>
<body onload="centerObj()">
<div id="MyDiv" style="width: 400px; max-width : 401px; height : 200px; max-height : 201px;">
<div style="border : 1px solid #048ab6; overflow: hidden; background-color : #f7f7f7">
<center>
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
<center>
</div>
</div>
</body>
</html>
I know is a lot to ask, but I'm debugging this a lot of time, and I don't found any solutions.
Thanks in advanced :'(