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 6 of 6

Thread: Centering

  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Centering

    #top_content_container {
    background-color:#fff;
    width:700px;
    height:100px;
    }

    I want to center this on the page, how would I do this without using position?

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Code:
    #top_content_container {
    background-color:#fff;
    width:700px;
    height:100px;
    margin:auto;
    }
    Ensure you have a valid doctype to make it work on IE as well.

    Hope that helps.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts
    This doesn't seem to be doing the trick in my case. Maybe its something that I'm doing wrong?

    body { background-image:url(/images/background5.gif);
    margin-top:0px;
    margin-bottom:0px;
    margin-left:0px;
    margin-right:0px;
    }

    #top_content_container {
    background-color:#fff;
    width:700px;
    height:100px;
    margin:auto;
    }

  • #4
    Regular Coder BoldUlysses's Avatar
    Join Date
    Jan 2008
    Location
    Winston-Salem, NC
    Posts
    938
    Thanks
    10
    Thanked 190 Times in 187 Posts
    Give this a shot:

    Code:
    body { background-image:url(/images/background5.gif); 
    width:100%;
    text-align:center;
    }
    
    #top_content_container {
    background-color:#fff;
    width:700px;
    height:100px;
    margin:0px auto;
    }
    matt | design | blog

  • #5
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Yes this works. Thanks again guys for you help.

    Jon W

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    body { background-image:url(/images/background5.gif);
    width:100%;
    text-align:center;
    }
    Quote Originally Posted by Jon W
    Yes this works. Thanks again guys for you help.

    Jon W
    You are running in quirks mode! Add/change your doctype and switch your document in to a standard one.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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