0

我希望使用条件类来检测是否正在使用 IE9,如果是,则将 css 相应地应用于类导航。

我在 html.tpl.php 文件中添加了以下行

<!--[if IE 9]><html <?php print $html_attributes; ?> class="ie9nav"><![endif]-->

在 stylsheet.css 文件中,当前类是(有效的)。

#navigation {background-image: blah.jpg}

我添加了

#navigation .ie9nav {background-color: fff;}

但它不起作用。我做错了什么?

4

1 回答 1

0

为什么不直接用php本身试试..

这是将派上用场的代码片段..

if(preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT']))
{
    echo '<html class="ieclass">';
}
else
{
    echo '<html class="none-ie">;
}

希望能帮助到你..

于 2013-04-18T11:30:33.040 回答