登录

html5 - 针对IE单独设置CSS

下面是我针对IE浏览器单独做的的CSS样式,为什么在IE下和在其他浏览器下的背景效果是一样的呢?
代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style >
        body{ background-color: #6db232; }
    </style>
    <!--[if IE]>
        <style >
        body{ background-color: #fff; }
        </style>
        <![endif]-->
</head>
<body>

</body>
</html>

# HTML
PHP中文网PHP中文网2183 天前787 次浏览

全部回复(2) 我要回复

  • 伊谢尔伦

    伊谢尔伦2017-04-17 12:10:31

    给一个较全面的处理方式

    <!--[if lte IE 6 ]> <html class="ie ie6 lte_ie7 lte_ie8 lte_ie9" lang="zh-CN"> <![endif]-->
    <!--[if IE 7 ]> <html class="ie ie7 lte_ie7 lte_ie8 lte_ie9" lang="zh-CN"> <![endif]-->
    <!--[if IE 8 ]> <html class="ie ie8 lte_ie8 lte_ie9" lang="zh-CN"> <![endif]-->
    <!--[if IE 9 ]> <html class="ie ie9 lte_ie9" lang="zh-CN"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html lang="zh-CN"> <!--<![endif]-->

    回复
    0
  • 阿神

    阿神2017-04-17 12:10:31

    <!--[if IE 8 ]><html class="ie8" lang="zh-cn"><![endif]-->
    <!--[if IE 9 ]><html class="ie9" lang="zh-cn"><![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--><html class="" lang="zh-cn"><!--<![endif]-->

    回复
    0
  • 取消回复发送