您的位置:首页 > 其它

关于ie中的hack以及条件注释方法

2016-10-12 14:25 381 查看
由于现在一般都最低要求只支持到ie8浏览器以上,所以不再管ie6 7

1:条件注释

ie中条件注释使用方法

<!--[if IE 5]>仅IE5.5可见<![endif]-->

<!--[if gt IE 5.5]>仅IE 5.5以上可见<![endif]-->

<!--[if lt IE 5.5]>仅IE 5.5以下可见<![endif]-->

<!--[if gte IE 5.5]>IE 5.5及以上可见<![endif]-->

<!--[if lte IE 5.5]>IE 5.5及以下可见<![endif]-->

<!--[if !IE 5.5]>非IE 5.5的IE可见<![endif]-->


gt : greater than,选择条件版本以上版本,不包含条件版本

lt : less than,选择条件版本以下版本,不包含条件版本

gte : greater than or equal,选择条件版本以上版本,包含条件版本

lte : less than or equal,选择条件版本以下版本,包含条件版本

! : 选择条件版本以外所有版本,无论高低

2:hack

\9

例子:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.tet{
width: 100px;
height: 100px;
background: #000;
background: red\9;
}
</style>
<!--[if gte IE 8.0]>
<style>
.tet{
background: red;
}
</style>
<![endif]-->
</head>
<body>
<div class="tet"></div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: