代码之家  ›  专栏  ›  技术社区  ›  Navneil Naicker

CSS样式表不适用于IE7和IE8

  •  0
  • Navneil Naicker  · 技术社区  · 11 年前

    我遇到了一个问题,站点仍然在我的本地主机中。其中css链接未包含在页面中。它可以在除IE7和IE8之外的所有其他浏览器中工作。

    我正在使用WordPress 3.6、Bootstrap 3、Modernizr和jQuery。

    源代码

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 ie-7"> <![endif]-->
    <!--[if IE 8]><html class="no-js lt-ie9 ie-8"> <![endif]-->
    <!--[if IE 9]><html class="no-js lt-ie9 ie-9"> <![endif]-->
    <!--[if gt IE 8]><!--><html class="no-js"> 
            <head>
          <meta charset="utf-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
          <title><?php echo title(); ?></title>
          <meta name="description" content="">
          <meta name="viewport" content="width=device-width">
          <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>/bootstrap.css"/>
          <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>/bootstrap-theme.css"/>
          <link href='http://fonts.googleapis.com/css?family=Maven+Pro:400,700' rel='stylesheet' type='text/css'>
          <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>/common.css"/>
          <?php if(is_front_page()){ ?><link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>/home.css"/><?php } ?>
          <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>/media.css"/>
          <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>/print.css" media="print"/>
          <script type="text/javascript" src="<?php echo JS_PATH; ?>/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
          <script type="text/javascript">var template = '<?php echo get_template_directory_uri(); ?>';</script>
        </head>
    

    铬合金头部 enter image description here

    IE8头 enter image description here

    我认为这可能与DOCTYPE有关,所以我改为HTML4,但它仍然不起作用。还要注意,它可以在IE8浏览器模式和文档模式下作为Quirks运行,但不能在标准模式下运行

    1 回复  |  直到 11 年前
        1
  •  3
  •   Quentin    11 年前

    您正在使用条件注释。

    <!--[if gt IE 8]><!--><html class="no-js"> 
            <head>
    

    你永远不会结束 <html> gt IE8的开始标记。下一条评论之前的所有内容都隐藏在与之匹配的浏览器中。

    添加 <!--<![endif]--> .