位置:固定和边距:0自动在IE中不工作 [英] Position:fixed and margin:0 auto not working in IE

查看:143
本文介绍了位置:固定和边距:0自动在IE中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用HTML和CSS编写了一个网站。

在这个网站中,我使用了两个属性 margin:0 auto 位置:固定多次。



问题是,网站正确显示在任何现代浏览器除IE 8 +以外。



我发现的另一个问题是在标题和浏览器窗口之间不应该有空格。再次,这只发生在IE浏览器。



这个问题通常与IE的怪癖模式有关。然而,在这种情况下,我正确设置了doctype <!DOCTYPE html>



可以检查出来的是: http://juancarlosoleacañizares.es/index.php?page = 0



我更喜欢没有使用JavaScript的解决方案。

解决方案

您的文档类型之前的非空格字符。文档类型应该是文档中的第一件事。因为这个IE认为meta标签和其他头元素是在你的身体内部。



如果您在IE9中打开开发人员工具(F12),您可以看到这一点。



W3验证器也会告诉你。显然它是一个字节顺序标记(BOM),应该省略。

学习使用这些工具是一件好事。它们对调试这样的问题至关重要。


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 header 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自动在IE中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆