0

在 OctoberCMS 中,我可以使用以下方法将 CSS 文件注入我的页面:

public function onRun()
{
    $this->addCss('http://yui.yahooapis.com/pure/0.6.0/grids-responsive-min.css');
}

我不知道,我怎样才能检查上面代码中的 IE 版本?OctoberCMS 中的以下 CSS 代码相当于什么?

<!--[if lte IE 8]>
    <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
    <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-min.css">
<!--<![endif]-->
4

1 回答 1

3

您作为参考发布的条件标记是 HTML 条件标记,因此不能在 PHP 方法中使用onRun

但是,您可以在主题布局或特定页面中使用相同的条件标记。

假设您正在使用demo主题。

  • themes/demo/layout/default.htm
  • 查找headHTML 文档的部分

粘贴您的代码:

<!--[if lte IE 8]>
    <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
    <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/grids-responsive-min.css">
<!--<![endif]-->```

请记住从您的方法中删除addCss调用onRun以避免添加相同的样式表两次。

于 2015-12-31T11:57:49.597 回答