...

View Full Version : Div won't center



Latchy
07-01-2010, 12:15 AM
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

Brucey2010
07-01-2010, 12:30 AM
Can you not give the DIV a width.


#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.

Donkey
07-01-2010, 02:28 AM
Youv'e got #contentdiv in twice


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

then


#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:

#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


* {
padding: 0;
margin: 0;
}
Should be the first line in your style sheet.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum