1 reply [Last post]
Last seen: 17 years 7 weeks ago
Timezone: GMT-5
Joined: 2004-03-18
Posts: 27
Points: 0

I'm having a problems trying to center all my divs. http://www.maxforcepc.com/ is my layout now. How would I center everything?


ClevaTreva's picture
A hilly place, UK
Last seen: 2 years 27 weeks ago
A hilly place, UK
Joined: 2004-02-05
Posts: 2902
Points: 0

Centering problem


For div's, it is necessary to define:


DO NOT use the margin: 0px auto; shortcut, as IE 5 Mac doesn't like it.

This works fine for everything EXCEPT IE Win.

For this try putting text-align:center as high up the design structure as you can if it still works, ie try body first, and work your way in till it works.

IF you apply it to a div, and inside that is another div with the same width, you must re-set the text-align back to left, or else IE Win will push the inner container outside its parent.

If all else fails, try adding postition:relative to get IE Win to work at not letting containers break out of their parents.

Also, for IE Win it isn't necessary, but for other browsers you may need to set a min-width to stop the content sliding off the left of the screen when the screen is re-sized too small.

Note that, depending on your css, it is possible that the IE text-align:center may not be on the same element as the left/right-margin:auto are.