Reputation: 15744
When putting someones old javascript function on my page it makes it no longer center in IE(7). What I think is causing it is the page width is getting superficially longer as a result of the script.
This is how I have it centered:
#container{width:960px; margin:0 auto;}
Here is what I have tried to fix it (needless to say it didnt work):
if (navigator.appName.indexOf("Microsoft")!=-1) {
document.getElementByID("container").style.marginLeft=(((document.body.offsetWidth - 960)/2));
}
Thank you ahead of time! :-)
Upvotes: 2
Views: 1437
Reputation: 2229
Totally agree with the posts above, had a lot of problems with IE before specifying a DOCTYPE, e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Upvotes: 3
Reputation: 8093
Internet explorer has had problems with margin:0 auto since the dawn of its creation. Its very picky.
Take a look at number 6 on this article and try that
http://www.webcredible.co.uk/user-friendly-resources/css/internet-explorer.shtml
Upvotes: 1