IE浏览器兼容的处理方式之一,使用特殊的注释

时间:2023-03-08 20:16:54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!--[if IE]>
<p>这里的代码在IE浏览器中可以执行,但在其他浏览器是不能执行的<p> <![endif]--> <!--[if lte IE7]>
<p>这里的代码在IE7一下浏览器中可以执行,但在其他浏览器是不能执行的<p> <![endif]-->
</body>
</html>

可以对具体的IE进行兼容,如

[if lte IE7] 其中lte是小于等于的意思,gte是大于等于的意思