www.webdeveloper.com
Results 1 to 4 of 4

Thread: positioning 'centering' problem

  1. #1
    Join Date
    Apr 2008
    Posts
    182

    positioning 'centering' problem

    hey its seems that i cannot center my wrapper and i am blind to why.
    i did margin : 0 autol have a doctype and just dont know why

    please take a look

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
     <title>
      Test
     </title>
     <style type="text/css">
     <!--
     * {
     margin: 0;
     padding: 0;
     }
     
     #wrapper{
      position: relative;
      margin:0 auto;
    	top: 100px;
     }
     -->
     </style>
    </head>
    <body>
    <div id="wrapper">
     Hello
     </div>
    </body>
    </html>
    http://www.mmtrials.com/layouts/test.php

    thanks
    Marcus

  2. #2
    Join Date
    Apr 2008
    Posts
    182
    ha figured it out! i am a nitwit! i didnt give a width - so wrapper was centerd for 100% of page; and the text i had wasnt aligned in anyway.

    sorry for post !
    thanks
    Marcus

  3. #3
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    Yes, for IE, a valid !doctype is required to make "margin:0 auto;" work, and also a stated width is required (includes any percent width as well as static width)

  4. #4
    Join Date
    Jun 2008
    Posts
    2

    Another trick for centering

    Once you add that width to the div definition, you can do something like this too:

    #Layer-1 {
    position: absolute;
    margin-left: -250px;
    left: 50%;
    top: +0px;
    width: 500px;
    height: 280px;
    z-index: 1;
    }

    make that negative margin-left equal to half the width and your in business.

    psd2css Online will generate that code for you from your photoshop file if you use the '_center' Layer Naming Convention.

    --
    Shaun
    shaun@psd2cssonline.com
    http://psd2cssonline.com
    Free, Fast and Easy CSS/XHTML Compliant web pages converted from your Photoshop files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles