【问题标题】:Including css files conditionally in OctoberCMS在 OctoberCMS 中有条件地包含 css 文件
【发布时间】:2016-04-05 06:33:58
【问题描述】:

在 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]-->

【问题讨论】:

    标签: css octobercms


    【解决方案1】:

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

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

    假设您使用的是demo 主题。

    • 转到themes/demo/layout/default.htm
    • 找到您的 HTML 文档的 head 部分

    粘贴您的代码:

    <!--[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]-->```
    

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

    【讨论】:

      猜你喜欢
      • 2012-04-21
      • 2013-02-28
      • 2013-09-17
      • 2013-04-10
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 2019-09-19
      • 2011-11-01
      相关资源
      最近更新 更多