Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html IE条件注释不起作用_Html_Css_Internet Explorer_Conditional Comments - Fatal编程技术网

Html IE条件注释不起作用

Html IE条件注释不起作用,html,css,internet-explorer,conditional-comments,Html,Css,Internet Explorer,Conditional Comments,我有一个用于所有桌面的style_desktop.css和另一个用于移动设备的style_mobile.css <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <link rel="stylesheet" media="screen and (min-device-widt

我有一个用于所有桌面的style_desktop.css和另一个用于移动设备的style_mobile.css

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<link rel="stylesheet" media="screen and (min-device-width:781px)" type="text/css"
      href="style_desktop.css"/>
<link media="only screen and (max-device-width: 780px) and (min-device-width: 320px)"
      href="style_mobile.css" type="text/css" rel="stylesheet"/>
除IE 8及以下代码外,上述代码工作正常。我想这是因为IE8及以下版本无法识别最小设备宽度:781px

因此,我更新了代码如下,但它仍然不工作

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<link rel="stylesheet" media="screen and (min-device-width:781px)" type="text/css"
      href="style_desktop.css"/>
<link media="only screen and (max-device-width: 780px) and (min-device-width: 320px)"
      href="style_mobile.css" type="text/css" rel="stylesheet"/>
 <!--[if lt IE 9]>
      <link rel="stylesheet" type="text/css" href="style_desktop.css"/>
 <![endif]-->
如果是任何桌面浏览器,则我希望链接style_desktop.css。 如果是任何移动浏览器,则我希望链接style_mobile.css

通过测试,我发现条件注释不起作用

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<link rel="stylesheet" media="screen and (min-device-width:781px)" type="text/css"
      href="style_desktop.css"/>
<link media="only screen and (max-device-width: 780px) and (min-device-width: 320px)"
      href="style_mobile.css" type="text/css" rel="stylesheet"/>
 <!--[if lt IE 9]>
      <link rel="stylesheet" type="text/css" href="style_desktop.css"/>
 <![endif]-->
编辑:
我正在使用wordpress,如果有什么不同的话。我已经删除了get_template_directory_uri;为了清晰起见,请从href中选择。

您可以尝试为旧版IE启用HTML5和CSS3:

<!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->

这有帮助。我在IE的兼容模式下测试它。它没有在那里显示,但在实际工作中。检查