日期:2014-05-17  浏览次数:20745 次

<!--if ie >语句为什么不起效果?有代码,请指教
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>


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

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

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


 <!--[if it IE 9]>
<link href="ie9.css" type="text/css" rel="stylesheet" />
<![endif]-->
</head>

<body>
<div id="ifie_test"> 如果是ie6,则字体为红色。<br />
  如果是ie7,则字体为绿色。<br />
  如果是ie8,则字体为蓝色。<br />
  如果是ie9,则字体为黄色。 </div>
 
</body>
</html>


怎么在不起效果?

------解决方案--------------------
条件注释中没有it这个运算符。http://zh.wikipedia.org/zh/条件注释

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

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

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

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

------解决方案--------------------
<!–[if IE 8]> = IE8 仅IE8可识别
<!–[if lt IE 8]> = IE7或更低版本
<!–[if gte IE 8]> = 高于或者等于IE8版本

IE6.0 7.0 8.0 9.0的Css if hack条件语法操作说明
------解决方案--------------------
文件路径有问题吗,4个CSS不在同一个目录中?
------解决方案--------------------
把修改后的html代码发上来看看。
------解决方案--------------------
看不出有什么问题,比如我加下面这样一行条件注释,然后设置IE9的浏览器模式为IE7后浏览,代码是有效的。
HTML code
<!--[if IE 7]>
<style type="text/css">
#ifie_test { font-size:24px; color:blue; }
</style>
<![endif]-->

------解决方案--------------------
探讨
看不出有什么问题,比如我加下面这样一行条件注释,然后设置IE9的浏览器模式为IE7后浏览,代码是有效的。

HTML code
<!--[if IE 7]>
<style type="text/css">
#ifie_test { font-size:24px; color:blue; }
</style>
<![endif]-->