Positioning DIV element at center of screen
- by iSumitG
I want to position a DIV (or a TABLE) element at the center of screen irrespective of screen size. In other words, the space left on 'top' and 'bottom' should be equal and space left on 'right' and 'left' sides should be equal. How to do it?
Note: I prefer a complete CSS solution, but if is not possible without Javascript then using Javascript is also fine.
I am trying the following but it is not working:
<body>
<div style="top:0px; border:1px solid red;">
<table border="1" align="center">
<tr height="100%">
<td height="100%" width="100%" valign="middle" align="center">
We are launching soon!
</td>
</tr>
</table>
</div>
</body>
Note: It is either way fine if the DIV element (or TABLE) scrolls with the website or not. Just want it to be at center when page loads.