为什么我的 IE6 条件样式表不起作用?

发布于 2024-08-20 08:02:03 字数 354 浏览 15 评论 0原文

这让我抓狂。我正在尝试使用条件 IE6 样式表。 我在此处发布了此测试页面。以下是我放置在 head 标签中的代码:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

在 IE6 中查看时,ie6.css 应将正文背景设置为红色。

这是怎么回事?我确信这是愚蠢的事情。有人可以向我指出吗?

This is driving me nuts. I'm trying to use a conditional IE6 stylesheet. I posted this test page here. Here is the code I placed in my head tags:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

The ie6.css should set the body background to red when viewed in IE6.

What's wrong here? I'm sure it's something dumb. Could someone please point it out to me?

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

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

发布评论

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

评论(4

ˇ宁静的妩媚 2024-08-27 08:02:03

它对我来说效果很好。通过 IE NetRenderer 运行您的测试页,您将看到红色背景。也许您正在 IE 6 以外的版本中测试它?

It works fine for me. Run your test page through IE NetRenderer and you'll see the red background. Perhaps you're testing it in a version of IE other than 6?

鲸落 2024-08-27 08:02:03

您碰巧没有使用 IETester

因为使用 IETester,条件注释将始终解析为安装的最高 IE 版本。

You don't happen to be trying this using IETester?

Because with IETester, Conditional Comments will always resolve to the highest installed version of IE.

我们只是彼此的过ke 2024-08-27 08:02:03

CSS 文件是否位于根文件夹(与 HTML 相同的文件夹)中?将 CSS 放在单独的文件夹中是一个很好的做法。

<!--[if IE 6]><link href="css/ie6.css" rel="stylesheet" type="text/css" /><![endif]-->

is the CSS file in the root folder (same folder as the HTML) ? it's good practice to put your CSS in a separate folder.

<!--[if IE 6]><link href="css/ie6.css" rel="stylesheet" type="text/css" /><![endif]-->
愿得七秒忆 2024-08-27 08:02:03

我刚刚遇到了类似的问题。条件注释无法正常工作,我尝试了一切。问题是我在标头中有一个与 X UA 兼容的元标记,这显然会影响渲染。因此,请继续留意这一点,因为这可能是一个原因。

<meta http-equiv="X-UA-Compatible" content="IE=7" />

I just had a similiar issue. The conditional comments did not work correctly and I tried everything. The issue was that I had an X UA compatible meta tag in the header which obviuously influences the rendering. So keep watching out for that because that can be a reason.

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