mkas
mkas

Reputation: 513

Center page in IE

I am trying to center page on IE. If I force quirk-mode by adding <!-- some comment --> before DOCTYPE declaration margin: auto; doesn't work properly and page is adjusted to the left. If I remove the comment page is centered, but some other elements are in mess. Could you give me some hints how to solve this?

Upvotes: 2

Views: 435

Answers (3)

Rob
Rob

Reputation: 15168

Of course, being in quirks mode is not where you want to be so quit doing that. The problem will lie with the rest of the markup but, unless you give us a link or a jsfiddle with the complete markup, anything we say will just be a wild guess.

Does the page work in a modern browser (anything but IE)?

Upvotes: 1

Jean-Fran&#231;ois
Jean-Fran&#231;ois

Reputation: 59

You can use a 50% margin, and a negative left position with half of your element size:

position: relative;
width: 600px;
margin-left: 50%;
left: -300px;

Upvotes: 0

James
James

Reputation: 13501

Setting margin-left: auto and margin-right: auto for the body using CSS usually does the trick.

Forcing quirks mode probably isn't a great idea, though.

Upvotes: 1

Related Questions