IE8出到现在还没敢装,前些天下载了个Xenocode Browser Sandbox安装了下,发现之前一直用的一个纯CSS横向导航的水平居中出了问题,在IE8下完全居左了。找了很久没发现问题所在,索性每份CSS分开屏蔽,最终确定是针对IE的CSS问题,得避掉IE8只对IE7及以下版本设置。

之前只是针对所有的IE浏览器:

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

要避掉IE8的话就得:

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

lt在此作小于用,也就是小于IE8的版本都能识别。

或者:

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

lte在此作小于及等于用,也就是小于及等于IE7的版本能识别。

或者:

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

<!–[if !(IE 8)]><![endif]–>在此单独避掉IE8版本。

在网上找了以下代码,测试了下有几个不符合:

1. <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
2. <!--[if IE]> 所有的IE可识别 <![endif]-->
3. <!--[if IE 5.0]> 只有IE5.0可以识别 <![endif]-->
4. <!--[if IE 5]> 仅IE5.0与IE5.5可以识别 <![endif]-->
5. <!--[if gt IE 5.0]> IE5.0以及IE5.0以上版本都可以识别 <![endif]-->
6. <!--[if IE 6]> 仅IE6可识别 <![endif]-->
7. <!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
8. <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
9. <!--[if IE 7]> 仅IE7可识别 <![endif]-->
10. <!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
11. <!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->

经过测试后:

5. <!--[if gt IE 5.0]> IE5.0以及IE5.0以上版本都可以识别 <![endif]-->

这个只有IE6以上的版本才可识别,也就是不包括IE5.0

7. <!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->

这个只有IE5以下的版本才能识别,也就是不包括IE6

10. <!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->

这个只有IE6以下的版本才能识别,也就是不包括IE7

后来才在经典那找到:

gt = Great Then 大于 &gt; = > 大于号
lt = Less Then 小于 &lt; = < 小于号
gte = Great Then or Equal 大于或等于
lte = Less Then or Equal 小于或等于

一下就明白过来了,还费了那么大劲。