如何让IE6,或指定浏览器识别某些css样式,但是其他浏览器不使用这些样式?
[已解决] 如何让IE6,或指定浏览器识别某些css样式,但是其他浏览器不使用这些样式?
当前页面:http://www.senparc.com/SZD-54
{ 收藏当前页面 }
20
[Web开发]
比如我有一个样式:
#iesixhide{display:none;}
只希望在IE6中使用这个样式,IE7/8和其他浏览器如Firefox等都不应用这个样式。并且是在客户端判断,服务器端输出的HTML都是一模一样的。
如何实现?
另外如果我想指定某个浏览器应用摸个样式,应该如何做呢?
#iesixhide{display:none;}
只希望在IE6中使用这个样式,IE7/8和其他浏览器如Firefox等都不应用这个样式。并且是在客户端判断,服务器端输出的HTML都是一模一样的。
如何实现?
另外如果我想指定某个浏览器应用摸个样式,应该如何做呢?
最佳答案
方法有很多,举两个例子:
一,使用!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标签
一,使用!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)
提交失败!请检查错误!错误信息:
以下信息或许对您有用:
- [已解决] 20 如何建网站?包括企业网站、电子商务网站、公司内部管理系统? 2010/9/23 15:53:03
- [已解决] 20 有没有好用且免费的在线Google Sitemap生成器?并且能正确够处网页理编... 2010/9/9 22:49:39
- [已解决] 5 什么是DMOZ开放式分类目录? 2010/7/24 12:27:07
- [已解决] 5 DMOZ分类目录对网站推广有什么作用吗? 2010/7/24 12:26:00
- [已解决] 10 如何在DMOZ分类目录登陆自己的网站? 2010/7/24 12:23:37