CSS浏览器兼容----IE的定制CSS样式

#条件声明(在另一篇文章中已有详细讲解说明了),也是解决IE兼容性最常用的方法

<!--[if IE 8]>
<style type="text/css">
	/* css for IE 8 */
</style>
<![endif]-->

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

#对于不同版本的IE相应的CSS规则,也是一种可选择的方式。

IE8及或下版本:添加9(\9)属性后

IE7或以下版本:添加属性前添加*

IE6:属性前添加_

.box {
	
	background: gray; /* standard */

	background: pink\9; /* IE 8 and below */

	*background: green; /* IE 7 and below */

	_background: blue; /* IE 6 */

}

#条件声明里面,添加<html>的Class:

这种方法是Paul Irish发明的,使用相应的IE class作为父类例如:

  .ie6 .box

<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]-->

 

<style type="text/css">
body {
	background: #efefef;
	font: 1em/1.5em Arial, Helvetica, sans-serif;
	color: #666;
	width: 80%;
	margin: 20px auto;
}
a {
	color: #F60;
}
.box {
	color: #fff;
	padding: 5px 20px;
	background: gray; 
}
.ie8 .box {
	background: pink;
}
.ie7 .box {
	background: green;
}
.ie6 .box {
	background: blue;
}
</style>

 

  

 

#下面是显示结果不同IE下的一个例子:

 VIEW DEMOIE Specific

 

转载于:https://www.cnblogs.com/IanI/p/4024342.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值