Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    88
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Very basic problem with centering

    This is so basic but it is eluding me:

    the css
    Code:
    * {
    margin:0;
    padding:0;
    }
    
    body{width:903px; text-align:center; background-color:#c4c6ba}
    the html
    Code:
    <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!

  • #2
    New Coder
    Join Date
    Mar 2008
    Posts
    88
    Thanks
    12
    Thanked 0 Times in 0 Posts
    SOLVED:

    margin: 0 auto;

  • #3
    Regular Coder
    Join Date
    Apr 2009
    Location
    Earth - sometimes sky :-)
    Posts
    121
    Thanks
    51
    Thanked 2 Times in 2 Posts
    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...
    Last edited by joda; 05-13-2009 at 03:56 AM.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,749
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello beedie,
    to center an element you need three things:
    1. a DocType
    2. an element with a width
    3. that elements right and left margins set to auto
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #5
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    check out Excavator's Sig.

    There is a bunch of info in them


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •