1 reply [Last post]
DiarYofaMadmaN
Offline
Regular
Last seen: 19 years 11 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?

-peace

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

Centering problem

Hi

For div's, it is necessary to define:

margin-left:auto;
margin-right:auto;
width:xxpx;

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.

Trevor