IE默认为怪异模式

发布于 2024-12-29 11:21:52 字数 588 浏览 3 评论 0原文

我正在制作一个 WordPress 主题,在 IE 中,在我的主题主页上,所有内容都左对齐,但在查看页面或帖子时,应该居中的所有内容都居中。

我已经尝试过从主页上删除几乎所有内容,但我仍然没有找到它的起源。

但奇怪的是,使用 IE 开发工具栏,将文档模式设置为 IE 8,使其工作起来就像一个魅力。但默认情况下,文档模式是 Quirksmode (这没有意义,因为我使用 DOCTYPE html

我尝试使用 X-UA 兼容元标记,但这也没有成功。

恐怕 因为它太多了。

我怎样才能强制 IE 不使用 Quirksmode?

我无法提供足够的代码, 屏幕可能会帮助您理解我的问题。

文档模式:Quirksmode(默认!问题!)

在此处输入图像描述

文档模式:IE 8 标准(修复了问题,但不是默认值!)

在此处输入图像描述

预先感谢您!

I'm making a wordpress theme, and in IE, on my homepage of the theme, everything is aligned left, but everything that should be centered is centered when viewing a page or post.

I have tried cutting out almost everything from the homepage and I still have not found the origin of this.

The weird thing is though, that using IE Developer Toolbar, setting the Document Mode to IE 8, makes it work like a charm. But by default, the Document Mode is Quirksmode (which makes no sense, since I use DOCTYPE html!

I tried using the X-UA Compatible metatag, but that did not do it either.

I'm afraid that I cannot provide enough code as it would simply be too much.

How can I force IE to not use Quirksmode? As I said, I tried everything I know, and everything I could find on google, and nothing helped.

Here are a few screenies that may help you understand my problem.

Document Mode: Quirksmode (DEFAULT! PROBLEM!)

enter image description here

Document Mode: IE 8 Standards (Fixes the problem, but not default!)

enter image description here

Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

走过海棠暮 2025-01-05 11:21:52

如果您仅在本地测试页面,则 IE 很可能因此而使用 Quirks 模式。尝试将页面上传到服务器上,再次测试,如果问题仍然存在,则发布 URL。 (这可能是 doctype 声明中的一些拼写错误。)另请参阅页面 http://hsivonen.iki.fi/ doctype/ 其中描述了 IE 在 Quirks Mode 问题中一些相当令人困惑的功能。

If you are testing the page locally only, the odds are that IE uses Quirks Mode just because of that. Try uploading the page on a server, test again, and post the URL if problems remain. (It could be some typo in the doctype declaration.) See also the page http://hsivonen.iki.fi/doctype/ which describes, among other things, some of the fairly confusing features of IE in the Quirks Mode issue.

已下线请稍等 2025-01-05 11:21:52

你有感叹号吗?它应该是

Do you have the exclamation point? It should be <!doctype html>.

初雪 2025-01-05 11:21:52

我弄清楚了问题所在 - Jukka 关于本地环境异常的说法是正确的,但为了解决它,我发现我必须将 X-UA-Compatible 元标记作为 Head 标记中的第一个标记才能工作。然而,我接受尤卡的回答,因为它是最有信息性的。 :)

I figured out what the problem was - Jukka was correct about the local environment being quirked, but to solve it, I found that I had to place the X-UA-Compatible metatag as the first thing in the Head tag for it to work. I am however accepting Jukka's answer as it is the most informative one. :)

人间☆小暴躁 2025-01-05 11:21:52

如果可以,请将您的文档类型更改

<!doctype html>

<doctype html>

第一个是 HTML5 文档类型,第二个不存在。

If you can, change your doctype to

<!doctype html>

Instead of

<doctype html>

The first is the HTML5 doctype, the second doesn't exist.

想你只要分分秒秒 2025-01-05 11:21:52

删除 DOCTYPE 标记之前的所有注释。

remove any comments before the DOCTYPE tag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文