PDA

View Full Version : CSS question, trying to get my page centered




Mike Teezie
Jun 10, 2005, 09:38 PM
Hey guys. A friend of mine's Dad asked me to build him a site for his local business. Here is what I have so far:

http://dopertees.com/rcbonline.htm

Please excuse the text and green blocks, they are just place holders.

Anyways, I like the way things are looking, I just want the whole "thing" to be in the center.

Is the reason it won't center up is because of the "position: absolute" values attributed? Is it possible to center my site?

I guess I could use a table to get it centered, but I'm trying to learn more about CSS. If I need to post anything else, I'd be more than happy to.

Any help would be greatly appreciated. Thanks in advance.

Here is my CSS:

body {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 12px;
background: url(http://dopertees.com/Images/bodyback.gif) ;
padding: 0;
}

#top {
width: 754px;
height: 167px;
background: url(http://dopertees.com/Images/topback4.gif);
}

#container {
width: 754px;
background: url(http://dopertees.com/Images/containerback2.gif);
position: absolute;
top: 167px;
text-align: center;
}

.link {
text-align: center;
padding: 115px
}

.container {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 12px;
}



davecuse
Jun 10, 2005, 10:57 PM
#container {
margin-left: auto;
margin-right: auto;
}


That should take care of it, also I would recommend putting the header within the container. You really don't need to use positioning for anything, I've found that simply using margins tends to work much better.

edit: one more thing... get the tables outta there! :eek:

Mike Teezie
Jun 11, 2005, 06:14 PM
Ah, thanks so much davecuse - that did the trick.

Of course, I woke up this morning, hated the look, and redid everything. But your css help made the whole re-do process much, much smoother.

Thanks!

brap
Jun 11, 2005, 06:30 PM
IIRC (any it's likely I don't), "margin:auto;" doesn't work inside Internet Explorer. Any version.

Mike Teezie
Jun 11, 2005, 06:44 PM
it sure doesn't brap.

I just had a friend check it, and it's back to the drawing board.

I hate Internet Explorer.

davecuse
Jun 11, 2005, 06:59 PM
I've really got to my windows test box hooked up again...

Mike Teezie
Jun 12, 2005, 01:38 PM
After some Googleing, I found a hack that will allow my page to be centered in IE.

Here it is. It's pretty vanilla, but the people I'm building it for want vanilla.

http://dopertees.com/rcbonline3.htm

scem0
Jun 13, 2005, 07:19 AM
Yeah, to make the margin-left/right: auto thing work in IE you have to give a text-align: center to the parent div or to the body element. That is how I center most of the things I center.

scem0

arf
Jun 18, 2005, 04:42 PM
This hack (http://www.bluerobot.com/web/css/center2.html) works pretty well, I think it's fine with IE too.