Log in

View Full Version : Why some of css doesn't work in IE?



auriaks
02-24-2010, 02:31 PM
Hi,

What commands of css are not working in IE? And how we can change them?

My webpage is floated: center, but in IE it still appears in left... Firefox and Opera shows it without any problems.

simcomedia
02-24-2010, 04:17 PM
The reason may be that there is no float: center; It's either left or right. If you want to center your page in the middle of the browser use this:

body {
margin: auto;
padding: 0;
}

Then a wrapper div :

#wrapper {
width: 900px;
margin: auto;
padding: 0;
}

auriaks
02-25-2010, 06:25 PM
An d why do I need wrapper? :)

auriaks
02-25-2010, 06:33 PM
works great :D

simcomedia
02-25-2010, 08:43 PM
I think you just answered your own question of why... :)

But, to further that, a wrapper is just a convenient way to apply centering to one element instead of all your elements. Plus, it's an easier way to make it cross-browser compatible. However, for older versions of IE (notably IE6) the old method was to 'trick' IE into centering your page by using:

body {
text-align: center;
}

#wrapper {
text-align: left;
}

Which centered the wrapper but within the wrapper the text would align left as normal.

auriaks
02-25-2010, 08:49 PM
thanks for info. :)