ie浏览器兼容性快速处理小招

时间:2023-03-09 15:49:47
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>
<title></title>
<style type="text/css">
html{font-weight:bold}/*all*/
*html{text-decoration:underline}/*for IE6*/
*+html{font-style:italic}/*for IE7*/
.tt
{
color:Red; /*all*/
#color:Green; /* for IE*/
*color:Blue; /* for IE7*/
_color:Gray; /* for IE6*/
}
</style>
</head>
<body>
<div class="tt">
ie6下你看见的是:加粗下划线灰色字体<br/>
ie7下你看见的是:加粗倾斜蓝色字体<br/>
其他浏览器你看见的是:加粗红色字体
</div>
</body>
</html>

以上是快速处理方法,当然,我们通常会这样写来区分浏览器:

<!--[if lt ie 9]>
......
<![endif]-->

这里要做一个特别的说明:就是IE特有的注释判断:

lte:就是Less than or equal to的简写,也就是小于或等于的意思。

lt :就是Less than的简写,也就是小于的意思。

gte:就是Greater than or equal to的简写,也就是大于或等于的意思。

gt :就是Greater than的简写,也就是大于的意思。

! : 就是不等于的意思,跟javascript里的不等于判断符相同,如<!--[if !ie]>,表示非IE浏览器下的设置

因为IE9虽然支持html5标签,但支持的不是很完整,所以,也可以写"lte",这取决于你的选择!