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

由于现在一般都最低要求只支持到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: red9;
        }
    </style>
    <!--[if gte IE 8.0]>
        <style>
            .tet{
                background: red;
            }
        </style>
    <![endif]-->
</head>
<body>
    <div class="tet"></div>
</body>
</html>
原文地址:https://www.cnblogs.com/joesbell/p/5952683.html