Monday, November 7, 2011

After thinking my website worked perfect on all browsers, IE8 came along and ruined it!! I can't wait for the day that Microsoft are banned from developing web browsers. The common CSS for centering a DIV on IE8 as shown below doesn't work:

#container{
margin:0 auto;}

To solve this you need the following CSS:


<!--[if (IE 6) | (IE 7) | (IE 8)]>
<style type="text/css">

body{
text-align: center;}

#container{
margin:0 auto;
text-align:left;
}
</style>
<![endif]-->


Using text-align: center; centers the DIV for IE, and the text-align: left; margin: 0 auto; will align the text to the left, and center the DIV for other browsers.

No comments:

Post a Comment