如何让IE6,或指定浏览器识别某些css样式,但是其他浏览器不使用这些样式?

[已解决] 如何让IE6,或指定浏览器识别某些css样式,但是其他浏览器不使用这些样式?

20
[Web开发]
比如我有一个样式:
#iesixhide{display:none;}
只希望在IE6中使用这个样式,IE7/8和其他浏览器如Firefox等都不应用这个样式。并且是在客户端判断,服务器端输出的HTML都是一模一样的。
如何实现?

另外如果我想指定某个浏览器应用摸个样式,应该如何做呢?
提问时间:2010/4/13 17:29:29 | 提问者:GaLiJiKuai | 悬赏:20 | 浏览:667
最佳答案
方法有很多,举两个例子:
一,使用!important:
iesixhide{
display:inline !important; /* IE7等样式,根据默认状态设置 */
display:none;  /* IE6 可读 */
}

二,在html代码中设置style:
<!–[if lte IE 6]>
<style type="text/css">
iesixhide{
display:none;  /* IE6 可读 */
}
</style>
<![endif]–>


除了专门限定IE6浏览器以外,还有下列方法:

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以下版本可识别 <![endif]–>
8. <!–[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]–>
9. <!–[if IE 7]> 仅IE7可识别 <![endif]–>
10. <!–[if lt IE 7]> IE7以下版本可识别 <![endif]–>
11. <!–[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]–>


条件注释语法:

[*]gt /Greater than/大于/<!–[if gt IE 5.5]>
[*]gte /Greater than or equal to/大于等于/<!–[if gte IE 5.5]>
[*]lt /Less than/小于/<!–[if lt IE 5.5]>
[*]lte /Less than or equal to/小于等于/<!–[if lte IE 5.5]>
[*]! /Note/不等于/<!–[if !IE 5.5]>

这些方法除了适用于style外,同样适用于script标签
回答时间:2010/4/13 17:43:24 | 回答者:zsu
其他参考答案(0)
提交失败!请检查错误!错误信息:

注:以上所有信息由网友提供,仅供交流、参考,均不代表盛派网络言论,如果有任何问题或不妥,请立即联系我们