jphchan
asked on
Centering items (horizontally and vertically) on a page?
Hi I've got a multi-layered, table object which I intend to use as a fancy entrance page to my site.
My problem is that I can't seem to get the items all centered in the middle of the screen. I'm using DreamWeaver to generate the page, and it works, but only for my own monitor resolution. It's off center if I look at it at another resolution. I tried modifying the DreamWeaver generated html, but it doesn't seem to work.
Does anybody have any suggestions?
I'd appreciate any insights you could bring.
Thanks!
My problem is that I can't seem to get the items all centered in the middle of the screen. I'm using DreamWeaver to generate the page, and it works, but only for my own monitor resolution. It's off center if I look at it at another resolution. I tried modifying the DreamWeaver generated html, but it doesn't seem to work.
Does anybody have any suggestions?
I'd appreciate any insights you could bring.
Thanks!
Do you have a url we can have a look at?
There probably isn't much point to us suggesting code to center without seeing what you are actually using.
There probably isn't much point to us suggesting code to center without seeing what you are actually using.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have you got it working yet?
ASKER
Thanks a lot! This was very helpful, and almost precisely what I needed.
Thanks! Glad it worked.
Set your content table inside an "outer" table which is set to a height and width of 100% (see code example). Make sure to 'valign="middle"' the "outer" table row (as in example), then set your content table to 'align="center"'.
Hopefully the code below should make this clearer. However, positioning your content with css, while possibly more work, would be better overall. I hope this code helps.
<!-- ## CODE ## -->
<html>
<!-- header tags removed -->
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<!-- "Outer" Table for positioning -->
<!-- note that height="100%" does not work with all browsers -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="middle"> <!-- note the valign="middle"-->
<td>
<!-- Main content table, note the align="center" attribute -->
<!-- table shaded for visual reference -->
<table width="600" bgcolor="#AAAAAA" align="center">
<tr><td align="center">This text should be centered</td></tr>
</table>
</td></tr>
</table>
</body>
</html>