I am trying to center page on IE. If I force quirk-mode by add开发者_Python百科ing <!-- 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?
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.
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)?
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;
精彩评论