【问题标题】:Using multiple stylesheets with WordPress在 WordPress 中使用多个样式表
【发布时间】:2013-04-09 22:27:07
【问题描述】:

我目前正在基于它们“_s”的基础创建一个新的 WordPress 主题。

有人可以向我解释一下如何将我的 style.css 文件拆分为多个文件以使它们更易于管理吗?例如,我希望将 layout.css、typography.css 和 other.css 文件存储在 /css 文件夹中。

我该如何设置。大概我需要在 header.php 文件中添加一些东西?

【问题讨论】:

    标签: css wordpress themes wordpress-theming


    【解决方案1】:

    只需通过<link /> 元素将它们包含在header.php 模板文件中。

    否则,您始终可以使用 CSS @import 函数:

    theme.css

    @import url("layout.css");
    @import url("typography.css");
    
    /* Other styles here: */
    body {
        margin: 0;
    }
    

    【讨论】:

      【解决方案2】:

      “只需​​通过 header.php 模板文件中的元素包含它们(在主样式表之下或之前,取决于层次结构)。”

      正如第一个回答者所说。

      “避免使用@import 指令”

      正如谷歌网站管理员所说 ;)

      [https://developers.google.com/speed/docs/best-practices/rtt#AvoidCssImport]

      编辑↓

      但是,我不建议使用多个样式表,因为更多的样式表意味着更多的 HTTP 请求并意味着更低的页面速度性能。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-08-25
        • 2015-01-10
        • 2015-04-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-11
        相关资源
        最近更新 更多