Forums

Centering My Template (5 posts)

  1. Misha
    Member
    Posted 7 years ago #

    I am developing my site and would like to center the entire template in the page. I have seen other templates that are centered but for the life of me cant seem to find an easy way to do it. Any help is much appreciated.

  2. Mark (podz)
    Support Maven
    Posted 7 years ago #

    Create a container for everything inside <body> then center that.

    <body>
    <div id="container">

    .
    .
    .
    .

    </div>
    </body>

    #container {
    margin: 0 auto
    }

    Tried that ?

  3. Wouldn't this work rather than the div?

    body { margin: 0 auto }

  4. Mark (podz)
    Support Maven
    Posted 7 years ago #

    Actually - isn't an IE statement needed ?
    Something like

    body {
    text-align:center
    }
    div {
    margin: 0 auto
    }

  5. dss
    Member
    Posted 7 years ago #

    Yes, and what a crippling hassle it all is when it doesn't make any sense! A good case for hand coding document style as opposed to using something like DreamWeaverwhich shows you such pretty pages, and then you panic and cry when they are displayed in IE (or any other browser sometimes.)

    for the body:

    body {
    margin: 0 auto;
    padding: 0 auto;
    text-align: center;
    }

    For the container:

    div.container {
    width: state width in pixels
    margin: 0 auto;
    }

    However, this doesn't always work... sadly I've found that sometimes a left margin is required to place sub div containers in the right place.

Topic Closed

This topic has been closed to new replies.

About this Topic