Html IE8 和怪癖模式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1245095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:30:11  来源:igfitidea点击:

IE8 and quirks mode

htmlcssxhtmlinternet-explorer-8

提问by Emily

Does IE8 run in quirks mode like IE6/7?

IE8 是否像 IE6/7 一样以 quirks 模式运行?

I have a webpage that has some truly bizarre code. The content is centered with padding and negative margins.

我有一个网页,里面有一些非常奇怪的代码。内容以填充和负边距为中心。

It works correctly in IE6/7 and other browsers but in IE8 the content area is half as wide and not centered (flag for quirks mode).

它可以在 IE6/7 和其他浏览器中正常工作,但在 IE8 中,内容区域只有一半宽且不居中(怪癖模式的标志)。

The source code has three blank lines before the DOCTYPE. I know that will throw IE6 into quirks mode. Will it also affect IE8?

源代码在 DOCTYPE 之前有三个空行。我知道这会使 IE6 进入怪癖模式。它也会影响IE8吗?

I don't have access to the source so I cannot remove those lines to test it.

我无权访问源代码,因此无法删除这些行进行测试。

采纳答案by Steerpike

Running a few quick tests that can be found hereseem to indicate that blank lines shouldn't throw IE8 into Quirks Mode (which is different to Compatability Mode that everyone seems to be confusing it with).

运行一些可以在这里找到的快速测试似乎表明空行不应该将 IE8 置于 Quirks 模式(这与每个人似乎都混淆的兼容模式不同)。

I wrote a breakdown on how incredibly confusing the different modes of IE8/7 hereand I didn't even include Quirks Mode in the breakdown. A detailed description of Quirks mode can be found here(not for the original question, but others might find it interesting.)

我写了一篇关于如何难以置信的混乱IE8 / 7的不同模式的崩溃在这里,我甚至没有包括Quirks模式击穿。可以在此处找到对 Quirks 模式的详细说明(不是针对原始问题,但其他人可能会觉得很有趣。)

回答by neb

Changing the doctype to HTML 5 should fix some problems. I had an issue with min-width in IE8 using Strict doctype.

将文档类型更改为 HTML 5 应该可以解决一些问题。我在使用 Strict doctype 的 IE8 中遇到了 min-width 问题。

So changed this:

所以改变了这个:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

To this: <!DOCTYPE html>

对此:<!DOCTYPE html>

See here: http://davidnaylor.org/blog/2008/09/ie8-and-max-width.html

见这里:http: //davidnaylor.org/blog/2008/09/ie8-and-max-width.html

回答by stk

Today, I changed our DOCTYPE from XHTML v1.0 (Strict) to HTML5. I read somewhere that even though the IE's don't recognize the DOCTYPE yet, they will render the page in standards-compliant mode.

今天,我将我们的 DOCTYPE 从 XHTML v1.0 (Strict) 更改为 HTML5。我在某处读到,即使 IE 还不能识别 DOCTYPE,它们也会以符合标准的模式呈现页面。

When I checked in IE8, the whole page looked whack (we have quite a bit of CSS and other styling). It took a while before I realized that there wasn't anything "wrong" with the CSS, or even IE8 for that matter. However, it WAS rendering in quirks mode.

当我检查 IE8 时,整个页面看起来很糟糕(我们有相当多的 CSS 和其他样式)。过了一段时间我才意识到 CSS 甚至 IE8 没有任何“错误”。然而,它是在怪癖模式下渲染的。

Inadvertently, I found the answer in the question posted here, specifically this comment: "The source code has three blank lines before the DOCTYPE. I know that will throw IE6 into quirks mode. Will it also affect IE8?"

不经意间,我在贴在这里的问题中找到了答案,特别是这个评论:“源代码在 DOCTYPE 之前有三个空行。我知道这会使 IE6 进入怪癖模式。它也会影响 IE8 吗?”

I don't know about blank lines, but when I made the change, I had used a javascript comment to "hang on to" my old DOCTYPE statement (which was ABOVE the new HTML5 DOCTYPE). Once I removed those lines (which may have included a blank line or two), my sweating stopped and IE8 rendered in standards-compliant mode.

我不知道空行,但是当我进行更改时,我使用了 javascript 注释来“保留”我的旧 DOCTYPE 语句(高于新的 HTML5 DOCTYPE)。一旦我删除了这些行(其中可能包含一两个空行),我的汗水就停止了,IE8 以符合标准的模式呈现。

回答by dalizard

Yes it does. Internet Explorer's quirks mode is IE5.5. IE6/7/8 switch back to 5.5 when quirks mode is present. So since it was working fine in IE6/7 it's not the quirks mode. There's a "Compatibility View" button in IE8 to address this issue. It's not a good solution to me though. You'll have to check your CSS code.

是的,它确实。Internet Explorer 的 quirks 模式是 IE5.5。存在 quirks 模式时,IE6/7/8 会切换回 5.5。因此,由于它在 IE6/7 中运行良好,因此它不是怪癖模式。IE8 中有一个“兼容性视图”按钮来解决这个问题。但这对我来说不是一个好的解决方案。您必须检查您的 CSS 代码。

回答by Greg D

IE8 has a compatibility mode which should treat the page the way IE7 would. Have you tried viewing the page in compatibility mode?

IE8 有一个兼容模式,它应该像 IE7 那样对待页面。您是否尝试过以兼容模式查看页面?

回答by shanabus

Can you post a link to the page or some of the HTML itself? You could try adding the meta tag to force compatibility mode?

您可以发布指向该页面或某些 HTML 本身的链接吗?您可以尝试添加元标记以强制兼容模式吗?

http://www.ditii.com/2008/08/28/ie8-standards-mode-and-ie7-compatibility-mode/

http://www.ditii.com/2008/08/28/ie8-standards-mode-and-ie7-compatibility-mode/

or for more info:

或了解更多信息:

http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx

http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx