Position:fixed 和 margin:0 auto 在 IE 中不起作用
我用 HTML 和 CSS 编写了一个网站。
在此网站中,我多次使用了 margin: 0 auto
和 position:fixed
属性。
问题是该网站在除 IE 8+ 之外的任何现代浏览器中都能正确显示。
我发现的另一个问题是标题和浏览器窗口之间不应该有空格。同样,这只发生在 IE 上。
此问题通常与 IE 的怪异模式有关。但是,在这种情况下,我正确设置了文档类型
网站的链接以便您可以查看此内容:http://juancarlosoleacañizares.es/index.php?page=0
我更喜欢不使用 JavaScript 的解决方案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档类型之前有非空格字符。文档类型应该是文档中的第一个内容。因此,IE 认为元标记和其他 head 元素位于您的体内。
如果您在 IE9 中打开开发人员工具 (F12),您可以看到这一点。
w3 验证器也会告诉你。显然它是一个字节顺序标记(BOM),应该被省略。
学习使用这些工具是一件好事。它们对于调试此类问题至关重要。
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.