IE的条件评论不起作用

时间:2013-03-07 22:45:13

标签: html

我正在尝试使用条件注释包含仅限IE7的样式表:

<head>
  <meta charset="utf-8">
  <title>Title</title>
  <meta name="description" content="Description">
  <link href="/static/styles/bootstrap.min.css" rel="stylesheet">
  <link href="/static/styles/font-awesome.min.css" rel="stylesheet">
  <link href="/static/styles/main.css" rel="stylesheet">
  <link href='//fonts.googleapis.com/css?family=Quicksand:700' rel='stylesheet' type='text/css'>
  <!--[if lt IE 9]>
    <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  <!-- [if IE 7]>
    <link type="text/css" rel="stylesheet" href="/static/styles/ie7.css">
  <![endif]-->
  <link rel="icon" type="image/png" href="/static/images/layout/favicon.png">
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>

我有一个Windows 7虚拟机(在VirtualBox上运行),我正在使用IE9中的开发人员工具将浏览器模式切换到IE7。引用的样式表中没有任何内容应用于页面。我正在加载所有其他样式表,我在所有内容上使用!important,并且我已经对文件名和路径进行了三重检查,但样式仍未应用。谁能看到我出错的地方?

1 个答案:

答案 0 :(得分:4)

有一个空格

<!--RIGHT HERE[... remove that one

之前:

<!-- [if IE 7]>
    <link type="text/css" rel="stylesheet" href="/static/styles/ie7.css">
 <![endif]-->

之后:

 <!--[if IE 7]>
    <link type="text/css" rel="stylesheet" href="/static/styles/ie7.css">
  <![endif]-->

不确定这是不是