开发者

Position:fixed and margin:0 auto not working in IE

I have coded a website in HTML and CSS.

In this website I have used both properties margin: 0 auto and position:fixed on several occasions.

The problem is that the website is correctly displayed in any modern browser except for IE 8+.

Another problem that I found is that there should not be a space between the h开发者_Python百科eader and the browser window. Again this only happens with IE.

This issues are usually related with the quirks mode of IE. However in this case I set the doctype correctly <!DOCTYPE html>

The link to the website so you can check this out is: http://juancarlosoleacañizares.es/index.php?page=0

I would prefer a solution without using JavaScript.


There are non space characters before your doctype. The doctype should be the very first thing in the document. Because of this IE thinks the meta tags and others head elements are inside your body.

You can see this if you open the Developer tools (F12) in IE9.

The w3 validator would have told you too. Apparently it is a byte order mark (BOM), which should be omitted.

It's a good thing to learn to use these tools. They're essential for debugging problems like this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜