3 replies [Last post]
pixel12345
Offline
newbie
Last seen: 5 years 35 weeks ago
Joined: 2008-05-19
Posts: 3
Points: 0

I am finding that my website aligns to the left despite the website container div's margin's being set to 'auto'. The site is perfectly fine and centred in firefox, but internet explorer 7 is totally not cooperating.

This site will need to be viewable on large screens as well as small ones, and so it should automatically center.

Any ideas anyone?

here is the css script for the website container div

/*main page frame*/ div.WebContainer{ width:1004px; margin-left:auto; margin-right:auto; background-color:ffffff; border:solid 1px #000; }

stinkysGTI
Offline
Regular
San Diego
Last seen: 6 years 6 weeks ago
San Diego
Joined: 2007-06-08
Posts: 26
Points: 0

Try adding this to the body

Try adding this to the body properties:

body {
text-align:center;
margin:0px auto;
}

Then, on your wrapper, add this:

div.WebContainer{
width:1004px;
background-color:ffffff;
border:solid 1px #000;
margin:0px auto;
text-align:left;
}

Usually in IE, text-align will work, but then you need to set it back to left alignment in the containing element.

pixel12345
Offline
newbie
Last seen: 5 years 35 weeks ago
Joined: 2008-05-19
Posts: 3
Points: 0

many thanks thats perfectly

many thanks
thats perfectly centered in firefox and IE7 now

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 9 hours 3 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9148
Points: 3132

If {margin: 0 auto;} doesn't

If {margin: 0 auto;} doesn't work in IE, it tells me you're in quirks mode. Be sure you're using a complete and proper DTD.

cheers,

gary

Unplanned code results in a tangled wad of brain-cramping confusion.

There are enough html & css demos and tutorials to be interesting. Please visit.