View Full Version : Div centered?


Donnerschlag
07-21-2005, 02:21 AM
Hey guys,

Im having problems with my div containter. I wish it to be centered on both FireFox and IE6+. The container displys the divs to the left and I wanted it centered like the banner.

CSS (http://onciuhosts.biz/test/main.css)

Site (http://onciuhosts.biz/test/)

Thnx in advanced.

Merike
07-21-2005, 08:57 AM
Change container's position:fixed; to position:relative; also you probably need to center the text of body for it to work in IE.

Donnerschlag
07-21-2005, 03:12 PM
Its not working, it makes the main text body expand to the sides but the nav stays in the same spot.

link (www.guildsofwarcraft.net)

Merike
07-21-2005, 04:28 PM
I see, that's because your navigation width:100%; stretches container aswell.

Try specifying width to mainbody and making it's margin:auto;

However your navigation is trickier since it uses floats, at the moment I don't have a solution for this :(

pb&j
07-21-2005, 04:58 PM
does this help?
http://bluerobot.com/web/css/center1.html

Donnerschlag
07-21-2005, 05:36 PM
Thanks so much. It works =)

Donnerschlag
07-21-2005, 05:50 PM
One other thing. If you look at the site in IE and FireFox the width of the news div is off. I tried setting it to 579px and 56.89em but they dont seem to match each other. Is there a way to fix this?

Merike
07-21-2005, 06:03 PM
Maybe width: 569px;?
Because the whole width of the div is width + padding + border.

kittycat
07-21-2005, 06:04 PM
Any padding you have on the sides will affect the width differently... one will add the padding on to the width (500px with 5px padding becomes 510px wide) and the other will include the padding in the width. There may be some CSS-type hacks that fix it, unfortunately I don't know of any though

Merike
07-21-2005, 06:07 PM
Any padding you have on the sides will affect the width differently... one will add the padding on to the width (500px with 5px padding becomes 510px wide) and the other will include the padding in the width. There may be some CSS-type hacks that fix it, unfortunately I don't know of any though
Isn't that the case in quirks mode? So if one adds document type declaration it will display the same in different browsers?

Donnerschlag
07-21-2005, 06:17 PM
ok thnx, ill try looking around.

nvm, a friend found it out for me.


you addd:


* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}


so your widths/padding/borders look the same in all browsers

Donnerschlag
07-21-2005, 06:21 PM
nvm, a friend found it out for me.


you addd:


* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}


so your widths/padding/borders look the same in all browsers

kittycat
07-21-2005, 06:32 PM
Isn't that the case in quirks mode? So if one adds document type declaration it will display the same in different browsers?

I have no idea, although I think I've had a problem both with and without a doctype...
And thanks for posting the solution you found donnerschlag, I'm definitely going to save that one

Donnerschlag
07-21-2005, 07:55 PM
np, and now my site is coming along smoothly =)