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 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    30
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Div won't center

    Hi,

    I am designing a website/demo page and have a div for the content to go into, only problem is. It wont center, I have tried everything from margin, padding, align. Can you help me please?

    Here is the link...
    http://www.graphiccentral.org/demopage-h10.htm

    Thanks,
    Rob

  • #2
    New Coder
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Can you not give the DIV a width.

    Code:
    #contentdiv{
    background-color:#C3C3C3;
    top: 80px
    width: 700px; */or whatever/*
    margin-left: auto;
    margin-right: auto;
    }

    I should have mentioned that by giving it a width you should be able to use margin-left margin-right auto to center it.

    Brucey.
    Last edited by Brucey2010; 06-30-2010 at 11:35 PM.

  • #3
    Regular Coder Donkey's Avatar
    Join Date
    Sep 2003
    Location
    Blackfield UK
    Posts
    311
    Thanks
    1
    Thanked 35 Times in 35 Posts
    Youv'e got #contentdiv in twice

    Code:
    #contentdiv {
    			top: 80px;
    			background-color: #c3c3c3;#
    			width: 70%;
    		}
    then

    Code:
    #contentdiv {
    			margin:0 auto;
    			width: 85%;
    			text-align: left;
    			position: fixed;
    			top: 130px;
    			background-color: #FFFEC9;
    			border: 1px solid #FADF8E;
    			-moz-border-radius: 6px;
    			-webkit-border-radius: 6px;
    			-khtml-border-radius: 6px;
    		}
    The second one overrides the first
    try this instead:
    Code:
    #contentdiv {
    			margin:130px auto 0 auto;
    			width: 85%;
    			text-align: left;
    			background-color: #FFFEC9;
    			border: 1px solid #FADF8E;
    			-moz-border-radius: 6px;
    			-webkit-border-radius: 6px;
    			-khtml-border-radius: 6px;
    		}
    Also you have your universal resets in the wrong place

    Code:
    * {
    			padding: 0;
    			margin: 0;
    		}
    Should be the first line in your style sheet.
    " 90% of everything is crud" - Theodore Sturgeon
    Filthy Beast - a 60's Rock Band


  •  

    Posting Permissions

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