...

View Full Version : Very basic problem with centering



beedie
05-12-2009, 03:52 PM
This is so basic but it is eluding me:

the css

* {
margin:0;
padding:0;
}

body{width:903px; text-align:center; background-color:#c4c6ba}

the html

<body>

<table cellpadding="0" cellspacing="0" border="0" width="903">
<tr><td colspan="3">
<img src="images/Header.png" alt="banner"
ALT="banner" BORDER="0" USEMAP="#map1" height="157" width="903 ">
</td>
</tr>
<tr>
<td align="left"><img src="images/leftside.png" alt="spacer" width="6" height="432"></td>
<td align="center"> FLASH GOES HERE </td>
<td align="right"><img src="images/rightside.png" alt="spacer" width="9" height="432"></td>
</tr>
<tr><td colspan="3"><img src="images/bottomshadow.png" alt="spacer"></td>
</tr>

</table>
<map name="map1" id="map1">
<area shape="rect" coords="760,75,900,110" alt="register" href="<?php echo site_url('register'); ?>" >

</map>
</body>

It just stays on the left.
I simply want the whole body to be in the middle.
I have done this hundreds of times but this time I don't see it!!
Help please!

beedie
05-12-2009, 04:07 PM
SOLVED:

margin: 0 auto;

joda
05-13-2009, 02:53 AM
Why you use tables instead of div tag?

here is some code for positioning the div element into the center of page:

<div id="global_div" style="width:500px; height:200px; margin-left:auto; margin-right:auto;">
here you can put another div left or right or up and down and so on...
</div>

This is just and idea...

Excavator
05-13-2009, 03:54 AM
Hello beedie,
to center an element you need three things:

a DocType
an element with a width
that elements right and left margins set to auto

sea4me
05-13-2009, 04:19 AM
check out Excavator's Sig.

There is a bunch of info in them :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum