internet explorer css body center
Wednesday, June 9th, 2010Internet Explorer hold the largest share in market and when it comes to deploying a website. Compatibility with IE matters more. there has been a problem I faced so many times. wondered how come MSN.com is not centered on IE unlike other browsers.
however generated this little trick that normally works.
body {
text-align: center;
min-width: 500px;
}
#wrapper {
text-align: left;
width: 500px;
margin-left: auto;
margin-right: auto;
}
Explanation
body {
text-align: center; /* MSIE 5 doesn't center based on auto left/right margins,
but 'text-align:center' does center top-level divs: */
min-width: 500px; /* Specify a min-width for the body as wide as the 'wrapper'
element itself. This prevents negative (i.e. inaccessible)
left-margins in narrow browser windows when using
Navigator 6+/Mozilla on Win32: */
}
#wrapper {
text-align: left; /* Reset alignment to compensate for 'text-align:center': */
width: 500px; /* Specify the width of the element. This should be the same
as 'body min-width': */
margin-left: auto; /* Set left and right margins to auto, thus centering the
element in the containing (body) tag: */
margin-right: auto;
}






