IE样式兼容写法

时间:2023-03-10 06:59:43
IE样式兼容写法

1、第一种写法

利用<!--[if lt IE 6/7/8/9/10/11]><![endif]-->,给每个html写一个class

<!DOCTYPE html>
<!--[if lt IE ]> <html class="ie ie6 lt-ie9 lt-ie8 lt-ie7"><![endif]-->
<!--[if IE ]><html class="ie ie7 lt-ie9 lt-ie8"><![endif]-->
<!--[if IE ]><html class="ie ie8 lt-ie9"><![endif]-->
<!--[if gt IE ]><!--><html><!--<![endif]-->
<head>
...

1、第二种写法

还是利用<!--[if lt IE 6/7/8/9/10/11]><![endif]-->,让dom单独引入样式:

    <!--[if lt IE  ]>
<link rel="stylesheet" type="text/css" media="all" href="/css/ie-hacks.css" />
<![endif]--> <!--[if lt IE ]>
<script src="/js/lib/placeholder-iehack.js"></script>
<![endif]-->